@neith/express
v0.1.5
Published
Typescript+Express+Jest boilerplate
Readme
- 📑 About the project
- 📦 Dependencies
- 📥 Package Manager
- 📂 Project Structure
- 🚀 Getting Started
- ⚙ Tests
- 🔍 SonarQube
- 📖 Docs
- 📝 License
📑 About the project
The server uses Winston and the native debug for log and debug.Winston is a logger for Node.js based on log4J.
The code written in TypeScript is transpilated to JavaScript using Esbuild. Esbuild is an open source compiler that is faster than Babel. Written in GO, tsx was used for project automatic build.In addition, the tsup for server bundle, which is faster than tsc.
For communication, Express has been selected for being a lightweight, easy-to-use framework. In addition. With adding a Rate Limit Middleware layer for the routes Express-rate-limit and Cors. And Helmet for security Helmet.
Finally, for unit tests the Jest was the framework responsible for unit tests performed. In addition, the supertest was used to test the routes with integration tests.
📦 Dependencies
Server:
- Express
- Express-rate-limit
- Express-winston
- Helmet
Run, Build and Test:
- Tsx - Esbuild
- Tsup - Esbuild
- Jest
Base:
- Cors
- Debug
- Dotenv
- Eslint
- Prettier
- Typescript
📥 Package Manager
The project was developed using PNPM, but you can use any of the package managers below:
📂 Project Structure
the root directory is src/ and contains the following files:
-> Middlewares # Validations, authentication, sanitization, etc.
-> Controllers # Endpoints, dice, etc.
-> Services # Business rules, logic, etc.├── __tests__/ # Integration tests
├── common/ # Common: general project core files
│ ├── config/ # Config files, like env variables
│ ├── constants/ # Constants files, like enums
│ ├── interfaces/ # Interfaces files
│ ├── types/ # Types files
│ └── utils/ # Utility files, like rules, logger, etc
├── modules/ # Modules: main fragments of the project
│ └── Hello/
│ ├── hello.controller.ts # Controller with the endpoints
│ ├── hello.middleware.ts # Middleware with the handlers
│ ├── hello.service.ts # Service with the main business
│ └── __tests__/ # Unit tests of module
├─ app.controller.ts # Controller file with all endpoints
├─ app.middleware.ts # Middleware file with general handlers
├─ app.service.ts # General services, like docs, static files...
└─ main.ts # Bootstrap the application🚀 Getting Started
Start by defining the environment variables:
Environment Variables
- PORT=3000
Install
npm installRun
npm run devRunning with docker 🐋
Just run:
docker-compose up -d⚙ Tests
npm run test
# And use test:watch for watch mode
npm run test:watch
# And use test:coverage for generate coverage report
npm run test:coverage🔍 SonarQube
npm run sonar📖 Docs
The REST API documentation is based on Openapi/Swagger is available at:
For now it is necessary to write the Documentation of the REST API manually, but will soon be generated automatically.
📝 License
This project is under the MIT license.
