Skip to content

A sample NestJS API server with postgres (prod), sqlite (dev) database and swagger api doc included. The App is generated using JHipster and later modified to remove user management and authentication features to keep it simple.

Notifications You must be signed in to change notification settings

gunamata/NestJS-API-Server

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.

NPM Version Package License NPM Downloads Travis Linux Coverage Discord Backers on Open Collective Sponsors on Open Collective

Description

NestJS Framework server project generated from official JHipster NodeJS blueprint. This sample project provides CRUD APIs implementation for a simple 'book' entity with title, author, isbn, publised, price as columns.

Features

-	dev, prod profiles
-	App flow diagram using arkit
-	typeorm for database interactions
-	unit tests, test coverage reports
-	Swagger API documentation
-	

Installation

$ npm install

TypeORM configuration

Define your prod database

For prod database configuration, in src/orm.config.ts change your url connection:

if(process.env.NODE_ENV==='prod'){
  ormconfig = {
      ...
      url: 'YOUR CONNECTION URL',
      logging: false,
      synchronize: commonConf.SYNCRONIZE,
      entities: commonConf.ENTITIES,
      migrations: commonConf.MIGRATIONS,
      cli: commonConf.CLI,
      migrationsRun: commonConf.MIGRATIONS_RUN,
  };
}

App Flow Diagram

# Generate flow diagram. Below command generates a file named arkit.svg in the folder. 
# The command uses npm package arkit.
$ npm run generate-flow-diagram

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# build and run in production mode
$ set NODE_ENV=prod&& npm run build && npm run start:prod

# run production build with node
$ set NODE_ENV=prod&& node dist/main.js

The app is served on http://localhost:8081. 
You can test the APIs using the Swagger API document page in your browser using the url http://localhost:8081/api/v2/api-docs/

You can specify dev or prod NODE_ENV value (default is dev as indicated in .env)

Lint

# run lint
$ npm run lint

# fix lint issues
$ npm run lint:fix

Debug

# run this and after you can execute debug task in VSCode
$ npm run start:debug

Test

# unit tests
$ npm run test

# lint
$ npm run lint

# fix lint issues
$ npm run lint:fix

# test coverage of unit tests
$ npm run test:cov

# e2e tests with full app coverage report
$ npm run test:e2e

Support

If you have any questions related to this sample application, Please feel free to contact me on LinkedIn, https://www.linkedin.com/in/gunasekhar-matamalam-5b06ab7b/ or e-mail me at [email protected] Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

License

Nest is MIT licensed.

About

A sample NestJS API server with postgres (prod), sqlite (dev) database and swagger api doc included. The App is generated using JHipster and later modified to remove user management and authentication features to keep it simple.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published