Skip to content

syskin/expressjs-boilerplate

Repository files navigation

ExpressJS Boilerplate

ci badge codecov GitHub version Sync Vulnerabilities Status

ExpressJS boilerplate structure with multiple datasources (Mongodb and static json used for demonstration) in ES5.

Requirements

  1. Node.js >= 10
  2. At least Mongodb (and as many datasources as you need)

Getting started

  1. Install packages:
    npm install
  2. Copy paste .env-example to .env and set up vars
  3. Run project in dev mode:
    npm run dev
  4. Run ESLint with Prettier for static analysis and applying consistent code formatting:
    npm run lint

Included in the boilerplate

  • Development & production environments
  • Tests (using Jest)
  • ExpressJS 4.x
  • Env vars config
  • Linting
  • Error handler

Boilerplate structure

  • 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)

Releases

No releases published

Packages