DEV Community

Cover image for API Project Template V2.0.0
Miftahul Arifin
Miftahul Arifin

Posted on

API Project Template V2.0.0

Several months ago, I posted API Project Template, Written in Typescript about boilerplate for building API project in Typescript.

Now, I made some changes especially in code style consistency, unit test coverage, swagger docs, and types.

What's new?

  • Improve coverage unit test on repositories and services using Jest

Unit test coverage

  • Refactor project structure as below
├── .husky/                     # Pre-commit config for lint staged
├── docs/                       # Swagger API docs
├── src/                        # All application source
├──── @types/                   # Type definition for modules
|
├──── api/
├────── controllers/            # Define all controllers
├────── middlewares/            # Define all middlewares
├────── models/                 # Define all sequelize models
├────── repositories/           # Define all repositories
├────── routes/
├──────── v1/                   # Define all v1 routes
├────── services/               # Define all services
├────── types/                  # Define all input types
|
├──── config/
├────── appConfig.ts            # Define app configuration
|
├──── constants/                # Define all constants
├──── database/                 # Define database connection and sync tables
├──── utils/                    # Define reusable libs
├──── server.ts                 # Create express config
├──── index.ts                  # ENTRYPOINT - Start server
|
└── ...
Enter fullscreen mode Exit fullscreen mode
  • Improve code style using class in repositories, services, and controllers
  • Add express validator as middleware to validate API request
  • and moreover...

See details of API Project Template v2.0.0 in this repo
arifintahu/project-structure-api - GitHub

Top comments (0)