/carma-tech-Api

Primary LanguageTypeScriptMIT LicenseMIT

Carma-Tech API, built based on nest-starter

build & test

Build a modular REST API with NestJS framework.

Table of Contents

What is this?

A REST API template based on NestJS with JWT auth, Open API 3.0 documentation, TypeORM integration already implemented.

Run(Dev Mode)

With Docker

cp .env.example .env
docker-compose up -d

Without Docker

Create dotenv file and fill it with proper values

cp .env.example .env

Install dependencies

yarn install

Run the application

yarn start:dev

HMR(Hot Module Reload) is configured with webpack, so you can use

yarn start

DB Migrations

If 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.

DB_SYNC should not be set to true in production. You may lose production data otherwise!

Generate a Migration

Make sure to use npm for commands follow, because yarn does not support $npm_config_name.

npm run migration:generate --name=AddAgeColumnToUser

Or with docker:

docker exec -it nest npm run migration:generate --name=AddAgeColumnToUser

Migration files are placed under src/migrations.

Run Pending Migrations

yarn migration:run

Revert a Migration

yarn migration:revert

Tests

# unit tests
yarn test

# e2e tests
yarn test:e2e

# test coverage
yarn test:cov

Environment Configuration

@nestjs/config is used, so you can just inject ConfigService to read environment variables from the dotenv file.

API Documentation

OpenAPI 3.0 is configured, and the API docs is hosted at BASE_URL/api/docs.

Authentication

JWT authentication is configured.

It would be greater to change the current password hashing to something more secure.

License

MIT

Maintainers

crazyoptimist