This is a big file upload example project written by nestJS.
- Nest
- MongoDB with typeorm
- class-validator
- Jest
- winston
- Helmet
- Multer
- Passport for
JWT
authentication - Support
hmr
and bundle server-side code with Webpack
Install dependencies
$ npm ci
or
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# watch mode with hot module replacement
$ npm run start:hmr
# debug app
$ npm run start:debug
# build app
$ npm run build
# launch in test environment
$ npm run launch:test
# launch in production environment
$ npm run launch:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
The example codebase uses Typeorm with MongoDB.
Create a new mongo database with the name db_net_disk
(or the name you specified in the config.db
)
Set database settings in congfig/index.ts
:
{
...other config
db: {
type: 'mongodb',
host: process.env.DATABASE_HOST || 'localhost',
port: parseInt(process.env.DATABASE_PORT || '27017', 10),
username: 'ndUser',
password: '123456',
database: 'db_net_disk',
synchronize: true,
logging: true
}
...other config
}
On application start, collections for all entities will be created.
.
βββ config: application config directory
βΒ Β βββ config.dev.js: config for development environment
βΒ Β βββ config.pre.js: config for pre production environment
βΒ Β βββ config.production.js: config for production environment
βΒ Β βββ config.test.js: config for test environment
βΒ Β βββ index.js: base config
βββ docs: project document directory
βββ src
βΒ Β βββ common: common directory
βΒ Β βΒ Β βββ dto: common dto directory
βΒ Β βΒ Β βββ entities: common entitie directory
βΒ Β βΒ Β βββ enums: common enum directory
βΒ Β βΒ Β βββ exceptions: common exception directory
βΒ Β βΒ Β βββ filters: common filter directory
βΒ Β βΒ Β βββ interceptors: common interceptor directory
βΒ Β βΒ Β βββ pipes: common dto directory
βΒ Β βββ utils: uility function directory
βΒ Β βββ modules: nest module directory
βΒ Β βΒ Β βββ user: user module directory
βΒ Β βΒ Β β βββ dto: dto directory for user module
βΒ Β βΒ Β β βββ entities: entity directory for user module
βΒ Β βΒ Β β βββ user.controller.ts: user controller
βΒ Β βΒ Β β βββ user.module.ts: user module
βΒ Β βΒ Β β βββ user.service.ts: user service
βΒ Β βΒ Β βββ file: file module directory
βΒ Β βΒ Β β βββ ...
βΒ Β βΒ Β βββ auth: auth module directory
βΒ Β βΒ Β β βββ ...
βΒ Β βΒ Β βββ app-logger: app logger module directory
βΒ Β βΒ Β βββ ...
βΒ Β βββ app.controller.ts: app controller
βΒ Β βββ app.controller.spec.ts: unit test for app controller
βΒ Β βββ app.service.ts: app service
βΒ Β βββ app.module.ts: app module
βΒ Β βββ main.ts: main entry
βββ test: e2e test directory
Β Β βββ app.e2e-spec.ts
Β Β βββ jest-e2e.json
See node-nestjs-frontend.
You can run node-nestjs
and node-nestjs-frontend
at the same time.So you can see the interaction effect.