Skip to content

Boilerplate started project for building RESTful APIs using Node.js and Express

Notifications You must be signed in to change notification settings

marcosvictorsb/boilerplate-api-node-express

Repository files navigation

BOILERPLATE API NODE EXPRESS

This boilerplate is intended to start an API, using Node.js, Express, Sequelize, JWT, Sinon for unit tests.

Features

  • Express + Sequelize
  • Request validation with joi
  • Linting with eslint
  • Tests with mocha, chai and sinon
  • Logging with winston
  • Load environment variables from .env files with dotenv

Requirements

  • Now using node v16.15.0 (npm v8.5.5)

Getting Started

Clone the repo:

  git clone [email protected]:MarcosVictorSB/boilerplate-api-node-express.git

Install dependencies:

  npm install

Set environment variables:

  cp .env.example .env

Running Locally

  npm run start

Units Tests

  # run all tests with mocha
  npm run test

Units Tests Coverage

  # command to run coverage unit tests
  npm run test:coverage

Project Structure

  src\
    |--config\                     # Environment variables and configuration related things
    |--domains\                    # Layer Domains
      |-- user\                    # Example a domain
        |-- adapter\               # Adapters
        |-- controller\            # Layer Controller
        |-- factories\             # Build main layers (controller, service and repository)
        |-- repositories\          # Layer Repository (container where something is deposited or stored)
        |-- routes\                # Layer Routes
        |-- services\              # Layer Service (Business logic)
        |-- validator\             # Request data validation schemas
    |--helpers\                    # EnumHelpers example: enumHelperCustomer, enumHelperAuthentication 
    |--infra\                      # Layer infra
      |-- database\                   
        |-- config\                # Config database: production, development
        |-- migrations\            # Migrations
        |-- models\                # Models
        |-- seeders\               # Seeders
    |--interfaces\                 # Main interfaces to system
    |--middlewares\                # Custom express middlewares    
    |--protocols\                  # Protocols http
  test/                            # Unit tests
app.js          
server.js        

About

Boilerplate started project for building RESTful APIs using Node.js and Express

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published