/nestjs-and-child-processing

Example how to use nestjs and child process to scale nestjs application

Primary LanguageTypeScriptMIT LicenseMIT

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 Gitter Backers on Open Collective Sponsors on Open Collective

Description

Nest framework TypeScript starter repository.

Example of how you can use child processing to fetch and manipulate response data from DB.

For the first time when you call /cats API you will receive a response from dbService. All next responses will be returned by components cache, but in the background, the cache will be updated/changed by the forked childProcessor which calls dbService.

This example is proof of concept of how you can use child processing. Two examples of child processing:

  • one example shows you how to fork child file for child processing
  • the second example shows you how to fork the whole NestJS module for child processing

Note: This is only proof of concept and It needs modification to be used in production environment.

Exposed API:

http://localhost:3000/cats

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Support

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.

Stay in touch

License

Nest is MIT licensed.