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

@asaje/nesty

v0.0.19

Published

## **Description**

Downloads

7

Readme

nesty

Description

A tool for easily configure NestJS/Prisma project based on yml file

Installation

npm i -D @asaje/nesty

or

yarn add -D @asaje/nesty

Getting started

# Step 1: Create a new nestjs project
nest g new my-project

cd my-project

You can follow the nestjs first steps guide here.

# Step 2: Install nesty as dependency
npm i -D @asaje/nesty
# Step 3: create your config.yml file
touch config.yml

# Write your configs
# Step 4: Use nesty to initialise your project
npx nesty config.yml init
# Step 5: Execute migrations and start your dev server
npm run migrate
npm run dev

Features (available commands)

init
Initialize a new empty project

# Eg:
npx nesty config.yml init

update
Use this command when your project is already configured and you want to make some updates

# Eg:
npx nesty config.yml update

gen:prisma
Use this command to only generate the prisma configs

# Eg:
npx nesty config.yml gen:prisma

gen:target
Use this command to only generate the config of a specific model or enum

# Eg:
npx nesty config.yml gen:target my-target

gen:db
Use this command to only generate the database configs

# Eg:
npx nesty config.yml gen:db

gen:env
Use this command to only generate the env configs

# Eg:
npx nesty config.yml gen:env

gen:sdk

Each time your project is built (the development server is started for example), a file named api.json is generated at the root of your project, this file is used to generate the equivalent sdk of your project.

# Eg:
npx nesty api.json gen:sdk

Write your config file

You can define in your configuration file five (5) configuration groups.

  • env: for the configuration of environment variables
  • database: for database configuation (only PostgresSQL databases are supported for the moment)
  • server: for server configuration
  • enums: list of all prisma schema enums
  • models: list of all prisma schema models

An example of config file is

env:
  dev:
    key: 'xxxxxxxxx'
  default:
    key: 'xxxxxxxxx'

database:
  dev:
    user: postgres
    pass: root
    port: 5432
    name: foo
    host: localhost

  default:
    user: john
    pass: p455w0rd
    port: 5432
    name: todo
    host: my.domain.app

server:
  port: 4300
  prefix: 'api'
  doc:
    title: 'TODO API'
    description: 'The todo API description'
    version: '1.0'
    path:
      swagger: 'docs'
      redocs: 'redocs'
    auth:
      user: 'admin'
      pass: 'admin'

enums:
  todo-status:
    - CREATED
    - PENDING
    - COMPLETED

models:
  todo:
    id:
      type: string
      id: uuid
    label:
      type: string
      validations:
        isString:
        minLength: 3
        maxLength: 10
    duration:
      type: int
      validations:
        isInt:
        min: 1
        max: 10
    status:
      type: enum
      enum: TodoStatus
      validations:
        isEnum: TodoStatus
    author:
      type: ref
      model: Author

  author:
    id:
      type: string
      id: uuid
    name:
      type: string

env

This is where you can specify all your env variables for your different environments. The syntax is:

# config.yml
env:
    env_name_1:
        key1: value1
        ...
        keyn: valueN
    ...
    env_name_N:
        key1: value1
        ...
        keyn: valueN

If you have two environments dev and prod for example, your configuration file should look like this

# config.yml
env:
  dev:
    api_key: xxxxxxxxx
  prod:
    api_key: xxxxxxxxx

As result, two files will be generated: .env.dev and .env.prod

NB: If you want to process .env without a specific environment suffix, you must use default as the environment name.

database

As for the env part, you can define database configurations for each of your working environments. The defaut environment is named default.

The available configurations are :

  • user: database username, default set to postgres
  • pass: database password, default set to root
  • port: database port, default set to 5432
  • name: database name, default set to test
  • host: database host, default set to localhost

server

The available configurations are:

  • port: the server port
  • prefix: the global api prefix, defautl set to api
  • doc: swagger and redocs configs

The available configurations for doc are:

  • title: the documentation page title
  • description: the documentation page description
  • version: the API version
  • path: the base paths for the documentation page. path.swagger defines the swagger path and path.redocs the redocs path
  • auth: the redocs page credentials. auth.user defines the username and auth.pass the password

enums

This is where you can specify all you enums.

The syntax is:

# config.yml
enums:
    enum_name_1:
      - value1
      - ...
      - valueN
    ...
    enum_name_N:
      - value1
      - ...
      - valueN

models

This is where you can specify all you models.

The syntax is:

# config.yml
models:
    model_name_1:
      column_name_1:
        attr_1: value1
        ...
        attr_N: valueN
      ...
      column_name_N:
        attr_1: value1
        ...
        attr_N: valueN
    ...
    model_name_N:
      column_name_1:
        attr_1: value1
        ...
        attr_N: valueN
      ...
      column_name_N:
        attr_1: value1
        ...
        attr_N: valueN

Available attributes are :

| Attribute | Possible values |   | | ----------- | ------------------------------------------ | --- | | id | increment, uuid, cuid | | type | string, int, float, bool, ref, enum, date  | | unique | true, false | | required | true, false | | default | the default value | | enum | the referenced enum | | model | the referenced model | | validations | one of available validations |

The available validations are:

  • min
  • max
  • minLength
  • maxLength
  • isInt
  • isDate
  • isEmail
  • isString
  • contains
  • isEmpty
  • isNotEmpty
  • isDefined
  • isOptional
  • equals
  • notEquals
  • isIn
  • isNotIn
  • isBoolean
  • isNumber
  • isArray
  • isEnum
  • isPositive
  • isNegative
  • minDate
  • maxDate
  • isBooleanString
  • isDateString
  • notContains
  • isAplha
  • isAlphanumeric
  • isDecimal