ExpressJS boilerplate structure with multiple datasources (Mongodb and static json used for demonstration) in ES5.
- Node.js >= 10
- At least Mongodb (and as many datasources as you need)
- Install packages:
npm install
- Copy paste
.env-example
to.env
and set up vars - Run project in dev mode:
npm run dev
- Run ESLint with Prettier for static analysis and applying consistent code formatting:
npm run lint
- Development & production environments
- Tests (using Jest)
- ExpressJS 4.x
- Env vars config
- Linting
- Error handler
- api (All relatives folder and file for the API)
- routes (Declare all endpoints of your API and call middleware, associate controller)
- controller (Control the data in and out of an endpoint and call needed services)
- middleware (Declare your middleware in this folder, usefull to execute some kind of code before calling a controller)
- services (Call functions, repository or dependencies to execute specific job)
- config (Folder of differents config file of your API project)
- repository (Declare your datasources and associated models to return data through services)
- tests (Tests folder)
- index.js (Main entry of expressJS server)