KyLeoHC / node-nestjs

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

License:MIT License


Languages

Language:TypeScript 97.7%Language:JavaScript 2.3%