Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kentloog/nestjs-sequelize-typescript

Nest + sequelize-typescript + JWT + Jest + Swagger
https://github.com/kentloog/nestjs-sequelize-typescript

Last synced: about 1 month ago
JSON representation

Nest + sequelize-typescript + JWT + Jest + Swagger

Awesome Lists containing this project

README

        

![Nest](assets/logo.png)

## Description

Starter kit project made with [Nest](https://github.com/nestjs/nest) that demonstrates CRUD user, JWT authentication, CRUD posts and e2e tests.

### Technologies implemented:

- [sequelize-typescript](https://github.com/RobinBuschmann/sequelize-typescript) (ORM) + [PostgreSQL](https://www.postgresql.org/)
- [JWT](https://jwt.io/)
- [Jest](https://jestjs.io/)
- [Swagger](https://swagger.io/)

## Prerequisites

- [Node.js](https://nodejs.org/) (>= 10.8.0)
- [npm](https://www.npmjs.com/) (>= 6.5.0)

## Installation

```bash
$ npm install
```

## Setting up the database for development and test

PostgreSQL database connection options are shown in the following table:

| Option | Development | Test |
| -------- | ----------- | --------- |
| Host | localhost | localhost |
| Port | 5432 | 5432 |
| Username | postgres | postgres |
| Password | postgres | postgres |
| Database | nest | nest_test |

## Running the app

```bash
# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod
```

## Test

```bash
# e2e tests
$ npm run test
```

## Other commands

```bash
# formatting code
$ npm run format

# run linter
$ npm run lint

# create database
$ npm run db:create

# run migrations
$ npm run db:migrate

# run seeders
$ npm run db:seed-dev

# reset database
$ npm run db:reset

# drop database
$ npm run db:drop

```

## Run production configuration

```
NODE_ENV=production \
DATABASE_HOST=db.host.com \
DATABASE_PORT=5432 \
DATABASE_USER=user \
DATABASE_PASSWORD=pass \
DATABASE_DATABASE=database \
JWT_PRIVATE_KEY=jwtPrivateKey \
ts-node -r tsconfig-paths/register src/main.ts
```

## Swagger API docs

This project uses the Nest swagger module for API documentation. [NestJS Swagger](https://github.com/nestjs/swagger) - [www.swagger.io](https://swagger.io/)
Swagger docs will be available at localhost:3000/documentation