0.1.5 ā€¢ Published 1 year ago

@neith/express v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

šŸ“‘ 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:

http://localhost:8080/docs

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.