npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nzod/dto

v1.0.1

Published

Create DTOs from N'Zod schemas

Downloads

9

Readme

Before you start

The README on main branch may contain some unreleased changes.

Go to release/latest branch to see the actual README for the latest version from NPM.

Navigation

Installation

NPM:

npm install @nzod/dto

Yarn:

yarn add @nzod/dto

Usage

Creating DTO from N'Zod schema

import { z } from '@nzod/z'
import { createNZodDto } from '@nzod/dto'

const CredentialsSchema = z.schema({
  username: z.string(),
  password: z.string(),
})

// class is required for using DTO as a type
class CredentialsDto extends createNZodDto(CredentialsSchema) {}

Validate data using DTO

// The value will be validated and parsed using CredentialsSchema
const value = 'Something possibly invalid'
const credentials = CredentialsDto.create(value)

@nzod/nestjs

The many functions from @nzod/nestjs accept DTOs.

You can learn more on @nzod/nestjs README page

Contributing

  1. Fork this repo
  2. Use the Regular flow

Please follow Conventions

Maintenance

The dev branch is main - any developer changes is merged in there.

Also, there is a release/latest branch. It always contains the actual source code for release published with latest tag.

All changes is made using Pull Requests - push is forbidden. PR can be merged only after successfull test-and-build workflow checks.

When PR is merged, release-drafter workflow creates/updates a draft release. The changelog is built from the merged branch scope (feat, fix, etc) and PR title. When release is ready - we publish the draft.

Then, the release workflow handles everything:

  • It runs tests, builds a package, and publishes it
  • It synchronizes released tag with release/latest branch

Regular flow

  1. Create feature branch
  2. Make changes in your feature branch and commit
  3. Create a Pull Request from your feature branch to main
    The PR is needed to test the code before pushing to release branch
  4. If your PR contains breaking changes, don't forget to put a BREAKING CHANGES label
  5. Merge the PR in main
  6. All done! Now you have a drafted release - just publish it when ready

Prerelease flow

  1. Assume your prerelease tag is beta
  2. Create release/beta branch
  3. Create feature branch
  4. Make changes in your feature branch and commit
  5. Create a Pull Request from your feature branch to release/beta
    The PR is needed to test the code before pushing to release branch
  6. Create Github release with tag like v1.0.0-beta, pointing to release/beta branch
    For next beta versions use semver build syntax: v1.0.0-beta+1
  7. After that, the release workflow will publish your package with the beta tag
  8. When the beta version is ready to become latest - create a Pull Request from release/beta to main branch
  9. Continue from the Regular flow's #5 step

Conventions

Feature branches:

  • Should start with feat/, fix/, docs/, refactor/, and etc., depending on the changes you want to propose (see pr-labeler.yml for a full list of scopes)

Commits:

Pull requests:

  • Should have human-readable name, for example: "Add a TODO list feature"
  • Should describe changes
  • Should have correct labels (handled by PR Labeler in most cases)