https://github.com/wavezync/nestjs-starter
Start your NestJS project quickly
https://github.com/wavezync/nestjs-starter
class-validator jwt jwt-authentication knex knexjs nest nestjs nestjs-backend nestjs-boilerplate nestjs-module nestjs-postgres nestjs-starter-template objection-orm objectionjs postgresql swagger typescript
Last synced: 6 months ago
JSON representation
Start your NestJS project quickly
- Host: GitHub
- URL: https://github.com/wavezync/nestjs-starter
- Owner: wavezync
- License: mit
- Created: 2021-09-02T04:53:24.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-06T16:09:41.000Z (about 1 year ago)
- Last Synced: 2024-05-06T17:34:56.115Z (about 1 year ago)
- Topics: class-validator, jwt, jwt-authentication, knex, knexjs, nest, nestjs, nestjs-backend, nestjs-boilerplate, nestjs-module, nestjs-postgres, nestjs-starter-template, objection-orm, objectionjs, postgresql, swagger, typescript
- Language: TypeScript
- Homepage:
- Size: 2.21 MB
- Stars: 19
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WaveZync NestJS Starter
## Description
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
In this starter you may find a working application pre configured with the PostgreSQL and JWT Auth.
Please go through [Nest Docs](https://docs.nestjs.com/) before playing with the code.
## Installation
To run the application you need to have **PostgreSQL** installed.
```bash
$ npm install
```### Running the app
```bash
# development
$ npm run start# watch mode
$ npm run start:dev# debug mode
$ npm run start:debug# production mode
$ npm run start:prod
```### Running the app with docker :whale:
With Docker you can run it easily. Now port `3000` will be open and `9229` can be connected to debugger as well.
**PostgreSQL** is exposed via `5432` port.
```bash
$ docker-compose up
```## Project Setup
The project setup follows standard NestJS conventions. Checkout NestJS docs for more.
### Directory structure
Directory structure follows module based on features.
```bash
src
├── @types # type defs goes here
├── common # common stuffs
│ ├── decorators # custom decorators
│ ├── dto # common DTOs
│ ├── exceptions # exceptions
│ ├── filters # filters for app
│ └── guards # guards for app
├── config # app config
├── database # database module
│ ├── migrations # db migrations
│ └── stubs # migration/seed stubs
└── modules # modules of app
├── auth # auth module
│ └── dto
├── health # health module
└── user # user module
├── dto
└── entities
```### Database and ORM
For database we have used PostgreSQL. And for ORM we have used [Knex.js](https://knexjs.org) with [ObjectionJS](https://vincit.github.io/objection.js).
Knex is an awesome query builder which is closer to SQL. Objection also a thin wrapper around Knex.
For all database migrations please use `snake_case` conversion when creating tables or columns.
In PostgreSQL it is natural to work with `snake_case` when writing queries.Knex will automatically map your `snake_case` names into `camelCase` on application side. Dont use `snake_case` in JS side. Instead always use `camelCase`. Read [more](https://vincit.github.io/objection.js/recipes/snake-case-to-camel-case-conversion.html)
> Please change the database name in docker-compose file and .env
### Api Docs
Api docs can be geneated thanks to `@nestjs/swagger` package. Since we are using `cli` plugin you can comment your `Dto`s with JSDocs and the documentation will be done automatically. Please follow conventions mentioned [here](https://docs.nestjs.com/openapi/cli-plugin)
- Access swagger docs at
- Access swagger.json at### Environment variables
| Env Variable | Description | example |
| ------------- | ---------------------------- | ----------------------------------------------- |
| SECRET | Secret for JWT | somesecret |
| DATABASE_URL | PostgreSQL connection string | postgres://admin:admin@localhost:5432/wavezync |
| LOGGER_LEVEL | Level of logger | info |
| LOGGER_FORMAT | Format for logging | pretty or json |### VS Code helpers
You can find helpers by pressing `CTRL + SHIFT + P` in VSCode