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.