nestjs-skeleton
nestjs-skeleton copied to clipboard
skeleton for Nest.js + TypeScript + TypeORM
nestjs-skeleton
Usage
| period | command | description |
|---|---|---|
| development | pnpm start:dev |
start server with auto reloading |
| development | pnpm start |
start server without auto reloading |
| development | pnpm start:debug |
start server with auto reloading and debugging |
| development | pnpm format |
format source codes |
| development | pnpm lint |
run eslint |
| development | pnpm test |
run tests |
| development | pnpm test:watch |
run tests with auto reloading |
| deploy | pnpm compile |
compile executable source of plain node |
| deploy | pnpm clean-compile |
cleanup, then compile executable source of plain node |
| deploy | pnpm clean |
cleanup compiled dists |
| production | pnpm start:prod |
start server |
Note the following points:
- The source codes are automatically formatted and linted before commit using husky.
- By default, development requires
pnpm. pnpm start:prodwill not automatically compile the sources.- Controllers in
/src/controllerand services in/src/servicewill be automatically loaded. As a consequence, those files cannot contain non-relevant function exports.
Development pipeline
Service
- create/find relevant services in
/src/service - add service to
/src/app.module.ts
Controller
- create/modify relevant controller in
/src/controller - add controller to
src/app.module.ts
Error
- create exception in
/src/common/errors.ts
Entity
- create entity in
/src/entity - generate migration with
pnpm db migration:generate --name <migration_name>
Config
- change
IEnvironmentin/src/common/config.ts - define schema according to compile errors
Default features
- nest.js
- TypeScript
- TypeORM database ORM with PostgreSQL database
- jsonwebtoken json web token
- pino logger
- envalid environment configuration loading
- Visual Studio Code integration
- husky git hooks
To-Dos
- [ ] unit & integration tests
- [ ] Docker support
- [ ] controller & service generation