Skip to content

A boilerplate for building RESTful APIs using Express, TypeORM with MongoDB or MySQL.

Notifications You must be signed in to change notification settings

Langsdorf/express-boilerplate

Repository files navigation

An Express and TypeORM with MongoDB or MySQL boilerplate

Quick Start

To create a project:

npx ebp-cli new <project-name>

Then

cd <project-name>
npm run start

Environment Variables

# Port number
PORT=3001

Project Structure

src\
 |--core\           # Core files
 |--modules\        # Modules files (controllers, services, entities, migrations...)
 |--index.js        # App entry point

Modules

The modules sounds like NestJS modules. To create a module:

Create a new folder inside modules directory:

    src\
     |--core\           # Core files
     |--modules\        # Modules files (controllers, services, entities, migrations...)
     |----new_module\   # New folder inside modules directory
     |--index.js        # App entry point

Create controller and service files inside your new folder:

    src\
     |--core\           # Core files
     |--modules\        # Modules files (controllers, services, entities, migrations...)
     |----new_module\   # New folder inside modules directory
     |------new_module.controller.ts
     |------new_module.service.ts
     |--index.js        # App entry point

Follow the existing examples for more information

Decorators

The list of available decorators can be found in the decorators file

Code example from status.controller.ts

import { GET, Response } from "@decorators";
import express from "express";
import StatusService from "./status.service";

export default class UserController {
  constructor(
    private readonly statusService: StatusService = new StatusService()
  ) {}

  @GET() //GET method, default path = /
  public async getStatus(@Response() res: express.Response) {
    res.send(await this.statusService.getStatus());
  }
}

About

A boilerplate for building RESTful APIs using Express, TypeORM with MongoDB or MySQL.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published