Giter Club home page Giter Club logo

scaffold-nestjs's Introduction

Scaffold Nest.js

Description

This generator will help you create a Nest.js application. You just need to answer the questions and get a ready-made application template.

Project Overview

  • Nest.js 9
  • Eslint
  • Docker
  • Husky
  • Supports MongoDB, MySql, Postgres
  • Supports Mongoose, Prisma, TypeORM, MikroORM
  • Ability to select services: Keycloak, MinIO and Novu

Installation

First, generate your new project:

npx scaffold-nestjs

Run your generated application:

cd <project name>
docker-compose up -d

Options

Options Description Example
skip-install This option disables installation of dependencies after code generation. npx scaffold-nestjs --skip-install
no-interactive This option disables answering questions in interactive mode. npx scaffold-nestjs --no-interactive
project This option allows you to set the name of the project (default is nest-js-project). npx scaffold-nestjs --project-name=nest-js-project
should-overwrite This option allows you to overwrite an existing folder. npx scaffold-nestjs --should-overwrite
database This option allows you to set the database.
Allowed values: mongo, mysql or postgres.
npx scaffold-nestjs --database=mongo
orm This option allows you to set the orm.
Allowed values for MongoDB: mongoose or prisma.
Allowed values for MySql and Postgres: prisma, mikroorm or typeorm.
npx scaffold-nestjs --orm=mongoose
no-need-auth This option disables the generation of authorization components. npx scaffold-nestjs --no-need-auth
auth This option allows you to set the authorization option.
Allowed values: jwt.
npx scaffold-nestjs --auth=jwt
services This option allows you to add various services to the project.
Allowed values: keycloak, minio, novu.
npx scaffold-nestjs --services=keycloak,minio

For example:

npx scaffold-nestjs --no-interactive \
  --should-overwrite \
  --project-name=nest-js-project \
  --database=mongo \
  --orm=mongoose \
  --services=keycloak,novu

App skeleton

├── src
│   ├── database
│   │   ├── migrations
│   │   │   └── ...
│   │   ├── database.config.ts
│   │   └── database-factory.service.ts
│   ├── decorators
│   │   ├── auth-bearer.decorator.ts
│   │   ├── auth.decorator.ts
│   │   ├── roles.decorator.ts
│   │   └── serialization.decorator.ts
│   ├── exceptions
│   │   └── validation.exceptions.ts
│   ├── filters
│   │   ├── all-exceptions.filter.ts
│   │   ├── bad-request-exception.filter.ts
│   │   ├── forbidden-exception.filter.ts
│   │   ├── index.ts
│   │   ├── not-found-exception.filter.ts
│   │   ├── unauthorized-exception.filter.ts
│   │   └── validation-exceptions.filter.ts
│   ├── guards
│   │   ├── jwt-access.guard.ts
│   │   ├── jwt-refresh.guard.ts
│   │   └── roles.guard.ts
│   ├── interceptors
│   │   ├── serialization.interceptor.ts
│   │   └── wrap-response.interceptor.ts
│   ├── interfaces
│   │   └── exception-response.interface.ts
│   ├── modules
│   │   ├── auth
│   │   │   ├── dtos
│   │   │   │   ├── jwt-token.dto.ts
│   │   │   │   ├── refresh-token.dto.ts
│   │   │   │   ├── login.dto.ts
│   │   │   │   └── signup.dto.ts
│   │   │   ├── interfaces
│   │   │   │   ├── decoded-user.interface.ts
│   │   │   │   ├── jwt-strategy-validate.interface.ts
│   │   │   │   ├── login-payload.interface.ts
│   │   │   │   └── validate-user-output.interface.ts
│   │   │   └── strategies
│   │   │   │   ├── jwt-access.strategy.ts
│   │   │   │   ├── jwt-refresh.strategy.ts
│   │   │   │   └── public.strategy.ts
│   │   │   ├── auth.controller.ts
│   │   │   ├── auth.module.ts
│   │   │   ├── auth.repository.ts
│   │   │   └── auth.service.ts
│   │   └── user
│   │       ├── dtos
│   │       │   ├── update-user.dto.ts
│   │       │   └── user-response.dto.ts
│   │       ├── user.entity.ts
│   │       ├── user.controller.ts
│   │       ├── user.module.ts
│   │       ├── user.repository.ts
│   │       └── user.service.ts
│   ├── shared
│   │   ├── services
│   │   │   ├── api-config.service.ts
│   │   │   ├── keycloak.service.ts
│   │   │   ├── minio.service.ts
│   │   │   └── novu.service.ts
│   │   └── shared.module.ts
│   ├── app.module.ts
│   └── main.ts
├── .dockerignore
├── .env
├── .eslintrc.js
├── .gitignore
├── .prettierrc
├── docker-compose.yml
├── Dockerfile
├── nest-cli.json
├── package.json
├── README.md
├── tsconfig.build.json
└── tsconfig.json

Links

Swagger documentation will be available on route:

http://localhost:3000/api

scaffold-nestjs's People

Contributors

vdyakov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

killinit

scaffold-nestjs's Issues

[NG-8] Add validation to incoming options

The database option can only include values: mongo, mysql or postgres.
The orm option can only include values: mongoose or prisma (for MongoDB) and prisma, mikroorm or typeorm (for MySql and Postgres).
The auth option can only include values: jwt.
The services option can only include values: keycloak, minio or novu.

Also add validation on incoming options (clear what shouldn't be there).

[NG-1] Improve project architecture

Prepare the structure:

-- generators/
---- module
------ generator
-------- steps/
-------- templates/
-------- index.ts - class of AbstractGenerator
------ questionnaire
-------- index.ts - class of AbstractQuestionnaire
------ index.ts - class of AbstractModule
-- lib/
---- collectors/
------ module-collector.ts
------ module-collector-handler.ts
---- package-managers/
---- runners/
---- generator.ts - abstract class
---- questionnaire.ts - abstract class
---- module.ts - abstract class
-- utils/
-- index.ts

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.