A progressive Node.js framework for building efficient and scalable server-side applications, heavily inspired by Angular.
<p align="center">
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
<a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
<a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
<a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
</p>
<!--[](https://opencollective.com/nest#backer)
[](https://opencollective.com/nest#sponsor)-->
NestJS Framework server project generated from official JHipster NodeJS blueprint.
$ npm install
As default your project will use an sqlite database (or a mongodb in memory). For prod database configuration, you don’t have to do nothing if you use a docker-compose with a project database image. To use other custom instance, in src/orm.config.ts change database, host, port, username and password according your values:
if(process.env.BACKEND_ENV==='prod'){
ormconfig = {
...
database: 'YOUR_DATABASE_NAME'
host: 'localhost',
port: 3307,
username: 'sa',
password: 'yourStrong(!)Password',
logging: false,
synchronize: commonConf.SYNCRONIZE,
entities: commonConf.ENTITIES,
migrations: commonConf.MIGRATIONS,
cli: commonConf.CLI,
migrationsRun: commonConf.MIGRATIONS_RUN,
};
}
To use it at runtime read the below section.
According typeORM migration guide, there are under src/migrations/ the scripts to create the database schema and after to insert data seed. The scripts are automatically run in the first start up, and after anymore.
# development
$ npm run start
# watch mode
$ npm run start:dev
# build transpiling files in javascript
$ npm run build
# run javascript build from the source project
$ npm run start:prod
# run javascript build with node
$ node dist/main.js
# build bundle with webpack
$ npm run webpack:prod
# run bundle with node (not require node_modules folder)
$ node dist/bundle.js
The app uses a BACKEND_ENV variable with dev default value in the .env file. If you change the value to prod, you will use the prod database at runtime as defined in src/orm.config.ts. You can also define all the variables that you want in that file. See https://www.npmjs.com/package/dotenv for the usage.
The standard values used from BACKEND_ENV are: dev, prod or test. You can define your custom value for BACKEND_ENV, but remember to add an application-{BACKEND_ENV}.yml file in your config folder, and a database configuration for that environment value, according the src/orm.config.ts.
If you don’t want to set a value in the .env file, you can specify its in the runtime process. For example:
# development in prod environment
# in linux
$ BACKEND_ENV=prod npm run start
# in windows
$ set BACKEND_ENV=prod&& npm run start
# run javascript build with node in prod environment
# in linux
$ BACKEND_ENV=prod node dist/main.js
# in windows
$ set BACKEND_ENV=prod&& node dist/main.js
# run bundle with node (not require node_modules folder)
$ node dist/bundle.js
The webpack build bundle automatically is configured for prod env, and can run without node_modules.
# run lint
$ npm run lint
# fix lint issues
$ npm run lint:fix
# run this and after you can execute debug task in VSCode
$ npm run start:debug
# 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
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.
Nest is MIT licensed.