A progressive Node.js framework for building efficient and scalable server-side applications.
<p align="center">
S - Single-Responsibility Principle - "Every class should have only one responsibility."
O - Open-Closed Principle - "Software Entities are open for extension, but closed for modification."
L - Liskov Substitution Principle - "Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it."
I - Interface Segregation Principle - "Clients should not be forced to depend upon interfaces that they do not use."
D - Dependency Inversion Principle - "Depend upon abstractions, not concretions."
Ex: To implement new entity/resource with exposed CRUD endpoints
nest g mo
) to keep code organized and establish clear boundaries (grouping related components)nest g co
) to define CRUD routes (or queries/mutations for GraphQL applications)nest g s
) to implement & isolate business logicnest g resource
Nest CLI resource generation docs:
Ex: Controller response object exposure
Nest detects when the handler is using either @Res() (<-- injectable decorators -->) or @Next(), indicating you have chosen the library-specific option. If both approaches are used at the same time, the Standard approach is automatically disabled for this single route and will no longer work as expected. To use both approaches at the same time (for example, by injecting the response object to only set cookies/headers but still leave the rest to the framework), you must set the passthrough option to true in the @Res({ passthrough: true }) decorator.
Ex: Docker YAML and start-up
/* YAML docker-compose.yml configuration file */
version: "3"
services:
db:
image: postgres // image to create db
restart: always
ports: // `port:port` allows access inside and outside docker
- "5432:5432"
environment:
POSTGRES_PASSWORD: pass123
// Start containers in detached / background mode
docker-compose up -d
// `docker-compose up [db] -d // <-- to start specific `service`
// ...if no services specified, will start all `services` in YAML
// Stop containers
docker-compose down
.spec.ts
spec files will reside in the same folder as the application source code files that they test..e2e-spec.ts
) are located in dedicated /test directory grouped by the feature/functionality that they test. (high level validation of entire system, closer to user experience @ production level)$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
$ docker exec -tiu postgres secret-stories-db-1 psql
<-- for psql shelldocker exec
: <-- runs a command inside a Docker container-t
: <-- allows interaction with CLI of container-i
: <-- (--interactive
) keeps the STDIN (standard input) open, even if not attached, allows us to provide input to the container's command-u
: <-- specifies user/username context, ensures command psql
is run as [username]postgres
: <-- provided [username] to match PostgreSQL connection (TypeOrmModule.forRoot({...}))secret-stories-db-1
: <-- docker container name, found in $ docker-compose up -d
terminalpsql
: <-- [command] to executepostgres=# \du
: <-- shows user informationpostgres=# \l
: <-- shows databasespostgres=# \c [database]
: <-- connect to && use dbpostgres=# \dt
: <-- list tables from current schemapostgres=# \d [table]
: <-- show table definitionNest is MIT licensed.