Skip to content

thienvx95/webbase

Repository files navigation

A Web Base for Node.js App.

Features

  • Express using Express.js web framework, and is using Typescript Lang for writing the app's logic.
  • Storing Custom Constant configurations within the process.env - DotEnv package is used.
  • Dependency Injection done with the nice framework from Inversify.
  • Clear Structure with different layers such as controllers, services, repositories, models, middlewares...
  • Easy Exception Handling thanks to routing-controllers.
  • Smart Validation thanks to class-validator with some nice annotations.
  • API Documentation thanks to swagger and routing-controllers-openapi.
  • API Monitoring thanks to express-status-monitor.
  • Basic Security Features thanks to Helmet.
  • Easy event dispatching thanks to event-dispatch.
  • Database Repo contains the use of Mongoose (ie. MongoDB object modeling for Node.js).
  • Logging Repo uses custom Log class built in middlewares folder using winston and it creates logs file by date & removes the log files after 'X' days (You can define that 'X' in the .env file).
  • Logging Middleware Repo uses middlewares folder using morgan for HTTP request logger middleware for node.js
  • Migrate Mongo thank to migrate-mongo for run automatic migration
  • Mongoose model thank to typegoose for define model using typescript classes

Global Requisites

  • node (>= 16.13")
  • tsc (>= 3.0.1)
  • typescript (>= 4.8")
  • mongoose (>= 6.8.1)

App Structure

├── dist
├── public
├── .logs - For log file save
├── src
│   ├── bussiness - For container bussiness of app
│   │   ├── auth - Handle Authen bussiness
│   │   │   ├── controller - For controller auto inject by convension ***.controller.ts
│   │   │   ├── model - Data to object of bussiness
│   │   │   ├── service - Handle bussiness of model
│   │   │   ├── subscribers -  Event Dispatch of model For created, updated, deleted auto inject by convension ***.subscriber.ts
│   │   ├── user - Handle User bussiness
│   │   │   ├── controller - For controller auto inject by convension ***.controller.ts
│   │   │   ├── model - Data to object of bussiness
│   │   │   ├── service - Handle bussiness of model
│   │   │   ├── subscribers -  Event Dispatch of model For created, updated, deleted auto inject by convension ***.subscriber.ts
│   ├── core
│   │   ├── configuration - get configuration of system by environment values
│   │   ├── data - define base repository and database provider 
│   │   ├── decorators - Dispatcher or Decorator for Class
│   │   ├── log - Customize log
│   │   ├── exception - exception handle error
│   │   ├── microframework - register loaders application 
│   │   └── ultis - constant, common functions
│   ├── entities - Models of entity
│   ├── infrastructures
│   │   ├── adapter - DI Adapter for routing controller
│   │   ├── auth - Handle authorzire middleware
│   │   ├── events - define event dispatch
│   │   ├── interceptors - auto inject interceptors with convention ***.interceptors.ts or init interceptors for bootrap
│   │   ├── middleware - auto inject middleware with convention ***.middleware.ts or init middleware for bootrap
│   │   ├── mapper - define auto mapper function
│   │   ├── migration - define migration function
│   │   ├── modules - register DI modules
│   │   ├── queue - define queue function 
│   │   ├── siteSetting - define site setting function 
│   │   ├── startup - define loader for bootrap
│   ├── migrations - migration folder
├── .env.dev
├── .env.production
├── .gitignore
├── package.json
├── README.md
├── tsconfig.json
└── tslint.json

About

Node js webApp

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors