@neith/express v0.1.5
- š 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 install
Run
npm run dev
Running 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.