Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Vivify-Ideas/nestjs-boilerplate
NestJS Boilerplate 😻(Authentication, TypeORM, Configuration, Swagger)
https://github.com/Vivify-Ideas/nestjs-boilerplate
boilerplate nestjs restful-api swagger typescript
Last synced: about 1 month ago
JSON representation
NestJS Boilerplate 😻(Authentication, TypeORM, Configuration, Swagger)
- Host: GitHub
- URL: https://github.com/Vivify-Ideas/nestjs-boilerplate
- Owner: Vivify-Ideas
- License: mit
- Created: 2018-10-14T14:31:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T22:13:59.000Z (over 1 year ago)
- Last Synced: 2024-11-06T03:48:02.391Z (about 1 month ago)
- Topics: boilerplate, nestjs, restful-api, swagger, typescript
- Language: TypeScript
- Homepage:
- Size: 1.59 MB
- Stars: 623
- Watchers: 30
- Forks: 90
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-nestjs - NestJS Boilerplate 💡 - 具有可用身份验证,typeorm,env 配置和 swagger 的 Boilerplate。开始制作伟大事物所需的一切。🚀 (资源)
- awesome-nestjs - NestJS Boilerplate - Boilerplate with available authentication, typeorm, env configuration and swagger. Everything you need to start making great things. (Resources)
README
NestJS Boilerplate
## Description
[NestJS](https://github.com/nestjs/nest) Boilerplate made with ❤️ by [💡VivifyIdeas💡](https://www.vivifyideas.com).
## Start Guide
### Outside Docker containers
- Create .env file `cp .env.example .env` and replace existing env variables
(mysql/mariadb connection params)
- Install dependencies `yarn`
- Start the app `yarn start` (app will be exposed through the port 3000)### Inside Docker containers
Just run already prepared bash script:
```bash
$ ./init
```
It will setup the project for you (starting docker-compose stack, running migrations).
The NestJS app running in dev mode will be exposed on `http://localhost` (port 80)For IDE autocompletion to work, run `yarn` on the host machine.
## TypeORM integrated
[TypeORM](http://typeorm.io/) gives you possibility to use next db types:
`mysql`, `postgres`, `mariadb`, `sqlite`, etc. Please look at docs for more details.
The `docker-compose` template uses `mariadb`.
## MigrationsIf you don't work on a production-ready project you can always change `DB_SYNC` env variable to true so you can play with NestJS without the need to write actual migrations.
**`synchronize: true` shouldn't be used in production - otherwise, you can lose production data.**
### Create Migration
Creating new migration is relatively easy and you can use typeorm CLI for that. You can run this command to create new migration:
```bash
$ docker exec -it nest yarn migration:create -n {CreateTableUsers}
```
Migration file will be placed under `src/migrations`. For more details check the existing [1611484925515-CreateUsersTable.ts](src/migrations/1611484925515-CreateUsersTable.ts)### Run Migrations
```bash
$ docker exec -it nest yarn migration:run
```
### Revert Migrations
```bash
$ docker exec -it nest yarn migration:revert
```## Test
```bash
# unit tests
$ docker exec -it nest yarn test# e2e tests
$ docker exec -it nest yarn test:e2e# test coverage
$ docker exec -it nest yarn test:cov
```## Environment Configuration
Integrated Configuration Module so you can just inject `ConfigService`
and read all environment variables from `.env` file, which is created automatically by the init script from `.env.example`.## Swagger
RESTful APIs you can describe with already integrated Swagger.
To see all available endpoints visit http://localhost/api/docs## Authentication - JWT
Already preconfigured JWT authentication.
It's suggested to change current password hashing to something more secure.
You can start use already working implementation of `Login` and `Registration`
endpoints, just take a look at [http://localhost/api/docs](http://localhost/api/docs).