Skip to content

Backend Template with Router-controlled-patterns for production ready api servers.

License

Notifications You must be signed in to change notification settings

sivsivsree/api-template

Repository files navigation

Node JS Backend Template

The templates are stuctured by Router-Controller-Model patterm

  • contollers/
  • exceptions/
  • models/
  • routes

Features!

  • Contollers

    • All the route logic goes
    • Files are named as <function>-contoller.js
  • Exceptions

    • All the errors are handled by the error.js file
    • define the default error template
    • The naming is based on the <function>-controller.js
    • Each controller has specific Error classes also
    class <function>Error extends Error {
        constructor(message) {
            super(message);
            this.status = 401;
            this.code = "UNAUTHORIZED";
            this.error = "ValidateError";
            this.msg = message;
        }
    }
  • Models

    • All the DB based operations are abstracted to this folder.
    • Also the naming is based on the <function>-model.js
  • Routes

    • All the application routes are defined over here
    • Naming <function>-routes.js, uses express router

Flow

Flow diagram

Run Test case:

$ mocha test/*-test.js
  • with Siv S

About

Backend Template with Router-controlled-patterns for production ready api servers.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published