A Microservice Template in NodeJS, TypeScript, and Express
Express + Routing-Controllers + TypeScript + TypeORM + TypeDI
npm install- Create .envfile from.env.exampleand populate environment variables
# Build and Run
npm start
# Run on local machine with watcher
npm run start:dev- TypeScript
- Depedency Injection of Services, Repositories, Controllers
- Modular App.ts
- Properly structured codebase models, repositories, services, controllers, migrations etc.
- ORM Migrations used for maintaining database schemas
- Follows pure REST APIs
- Input validations
-  Use of .envfile
- Git pre-commit hooks setup
- Linting and Standard Formatting
- Added system metadata like createdAt, updatedAt
- Use of DTOs
- Added audit log like createdBy, updatedBy
- isActive
- uuid as primary key
- Soft Delete Options
- Pagination
- Structured Logging
- Unit Testing
- Authentication
- Authorization
- Error Handling and Generic Error Middleware
- Search Framework
- AbstractService or interface Service
- Graceful Shutdown
- Containerized with Docker
- NodeJS with TypeScript
- ts-node and ts-node-dev for running on local machine
 
- Express Framework
- TypeORM - ORM Tool to interact with Database
- TypeDI - Dependency Injection library (https://github.com/typestack/typedi)
- routing-controllers - For Defining Routes in elegent way (https://github.com/typestack/routing-controllers)
- class-validator - For input validations (https://github.com/typestack/class-validator)
- class-transformer - For transforming objects (https://github.com/typestack/class-transformer)
- dotenv - Use Environment Variables from .env file
- ESLint - For Linting the ES and TypeScript codebase
- ext install dbaeumer.vscode-eslint
 
- Prettier - For Formatting Standard (https://eslint.org/docs/user-guide/getting-started)
- ext install esbenp.prettier-vscode
 
- Husky - https://github.com/typicode/husky
- lint-staged - https://github.com/okonet/lint-staged
- Create an entity: npm run typeorm -- entity:create -n User
- Generate migration: npm run typeorm -- migration:generate -n CreateUser
- Run the migrations: npm run typeorm -- migration:run
Notes:
- Migration name pattern: AddTo
- AddLastNameToUser
- UpdateEmailToEmployee
 
- Make use of index.tsin folder which has multiple files