Skip to content

KyLeoHC/node-nestjs

Repository files navigation

node-nestjs

This is a big file upload example project written by nestJS.

feature

Getting started

Installation

Install dependencies

$ npm ci

or

$ npm install

Running the app

# 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

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Database

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.

Project structure

.
β”œβ”€β”€ 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

Frontend

See node-nestjs-frontend.

You can run node-nestjs and node-nestjs-frontend at the same time.So you can see the interaction effect.

License

MIT License

About

πŸš€πŸ–¨A big file upload example project written by nestJS.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published