https://github.com/crazyoptimist/nest-starter
NestJS RESTful API starter for minimalists
https://github.com/crazyoptimist/nest-starter
boilerplate nestjs openapi3 rest-api starter-kit template typeorm typescript
Last synced: 11 months ago
JSON representation
NestJS RESTful API starter for minimalists
- Host: GitHub
- URL: https://github.com/crazyoptimist/nest-starter
- Owner: crazyoptimist
- License: mit
- Created: 2021-04-23T07:53:38.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-09-03T16:14:36.000Z (over 1 year ago)
- Last Synced: 2025-05-12T21:12:40.555Z (11 months ago)
- Topics: boilerplate, nestjs, openapi3, rest-api, starter-kit, template, typeorm, typescript
- Language: TypeScript
- Homepage:
- Size: 768 KB
- Stars: 6
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# NestJS Starter
[](https://github.com/crazyoptimist/nest-starter/actions/workflows/build.yml)
Build a modular REST API with NestJS framework.
## Table of Contents
- [What Is This?](#what-is-this)
- [Getting Started](#getting-started)
- [Database Migrations](#database-migrations)
- [Generate a New Migration](#generate-a-new-migration)
- [Run Pending Migrations](#run-pending-migrations)
- [Revert Migrations](#revert-migrations)
- [Tests](#tests)
- [Environment Configuration](#environment-configuration)
- [API Documentation](#api-documentation)
- [Authentication](#authentication)
- [License](#license)
- [Maintainers](#maintainers)
## What Is This?
This is a NestJS RESTful API starter that includes JWT authentication, OpenAPI 3 documentation, and TypeORM integration.
The reason I maintain it is because using this template allows you to quickly set up a production-ready RESTful API with minimal boilerplate code.
## Getting Started
Create a dotenv file and fill it out with the appropriate values.
```bash
cp .env.example .env
```
Install dependencies
```bash
npm install
```
Run the application
```bash
npm run dev
```
HMR(Hot Module Reload) is configured with webpack.
## Database Migrations
If you don't require incremental database migrations, set the DB_SYNC environment variable to true. This will continuously synchronize the database structure with the schema defined in the codebase.
__However, DO NOT set DB_SYNC to true in a production environment, as doing so may result in data loss!__
#### Generate a New Migration
Make sure to use npm for the following commands, as yarn does not support `$npm_config_name`.
```bash
npm run migration:generate --name=AddAgeColumnToUser
```
Migration files are located in the `src/migrations` directory.
#### Run Pending Migrations
```bash
npm run migration:run
```
Using Docker:
```bash
docker exec nest npm run migration:run
```
#### Revert Migrations
Revert the last migration
```bash
npm run migration:revert
```
## Tests
```bash
# unit tests
npm run test
# e2e tests
npm run test:e2e
# test coverage
npm run test:cov
```
## Environment Configuration
`@nestjs/config` has been used, so you can just inject `ConfigService` to read environment variables from the dotenv file.
## API Documentation
OpenAPI 3.0 has been configured, and the API documentation is hosted at `BASE_URL/api/docs`.
## Authentication
JWT authentication has been configured.
## License
MIT
## Maintainers
[crazyoptimist](https://crazyoptimist.net)