About Folder pattern for express rest api starterkit clean architecture, easy to scalable and easy to maintenance.
The following is a folder pattern for express rest api starterkit structure pattern that I usually use, so if you are interested in the pattern I made, you can use it if you think it's good, check this link for new update for this architecture here.
├── tests
│ └── test.user.spec.ts
├── di
│ └── di.user.ts
├── dto
│ └── dto.user.ts
└── helpers
│ └── helper.apiResponse.ts
└── middlewares
│ └── middleware.auth.ts
└── interfaces
│ └── interface.user.ts
└── models
│ └── model.user.ts
└── controllers
│ └── controllers.user.ts
└── services
│ └── service.user.ts
└── libs
│ └── lib.jwt.ts
└── configs
│ └── pm2.config.js
└── templates
│ └── activation.template.ejs
└── databases
│ └── migrations
│ │ └── user_20210913.go // generate auto by cli using third party library
│ └── seeds
│ │ └── user_20210913.go // generate auto by cli using third party library
Folder Name | Folder Status | Description |
---|---|---|
Tests | Optional | A collection of functions used to create a series of tests or run a test, be it unit testing or integration testing, which will later be used for the application itself. |
Folder Name | Folder Status | Description |
---|---|---|
Configs | Optional | A collection of functions that contains all the configurations related to the application needs, such as .env or serverless.yml, which will later be used for the application itself. |
Folder Name | Folder Status | Description |
---|---|---|
Di | Required | A collection of functions used to injected models database into services |
Folder Name | Folder Status | Description |
---|---|---|
Dto | Required | A collection of functions used to handle all requests body passed from the client. |
Folder Name | Folder Status | Description |
---|---|---|
Helpers | Optional | A collection of functions used to create utilities for application purposes, such as customError or customResponse, which will later be used for the application itself. |
Folder Name | Folder Status | Description |
---|---|---|
Interfaces | Optional | A collection of functions used to definition field property for model. |
Folder Name | Folder Status | Description |
---|---|---|
Libs | Optional | A collection of functions that are used for the purpose of customizing a library into a separate function, which will later be used for the application itself. |
Folder Name | Folder Status | Description |
---|---|---|
Middlewares | Optional | A collection of functions that are used as a service for HTTP Requests such as authJWt, authRole, customLogger whether used per-route or used globally without the need to use them in each route, which will later be used for the application itself. |
Folder Name | Folder Status | Description |
---|---|---|
Models | Required | A collection of functions used to represent the table structure in a database, which will later be used for the application itself. |
Folder Name | Folder Status | Description |
---|---|---|
Controllers | Required | A collection of functions used to handle all requests given client, which then those requests will be used to delivery request to service, which will later be used for the application itself. |
Folder Name | Folder Status | Description |
---|---|---|
Routes | Required | A collection of endpoints or addresses from the server itself, which is used for communication lines between the client and the server, which will later be used for the application itself. |
Folder Name | Folder Status | Description |
---|---|---|
Services | Required | A collection of functions that are used to interact with the database, which will later be used for the application itself. |
Folder Name | Folder Status | Description |
---|---|---|
Templates | Optional | A collection of functions that are used to output HTML code into emails to be used as templates, which will later be used for purposes such as activationCode or resetPassword, which will later be used for the application itself. |
Folder Name | Folder Status | Description |
---|---|---|
Crons | Optional | A collection of functions that are used to trigger a desired function, according to the time specified by the user, which will later be used for the application itself. |
Folder Name | Folder Status | Description |
---|---|---|
Databases | required | A collection of functions used to create migrations or seeds for the database, which will later be used for the application itself. |
$ npm install
$ npm run build || make build
$ npm run dev | make dev
$ npm run start || make start
$ npm run start:docker || make startdoc
$ npm run test || make test
$ npm run start:cov || make testcov
$ docker-compose build | make dcb
$ docker-compose up -d --<flags name> | make dcu f=<flags name>
$ docker-compose up -d --build --<flags name> | make dcubf f=<flags name>
$ docker-compose up -d --build | make dcu
$ docker-compose down | make dcd
$ npm run orm:make <migration name> || make ormake name=<migration name>
$ npm run orm:latest || make ormig type=latest
$ npm run orm:rollback || make ormig type=rollback
$ npm run orm:list || make list
$ npm run seed:config || make orscon
$ npm run seed:run || make orsrun type=run
$ npm run seed:runrollmig || make orsrun type=runrollmig