Skip to content
A strong starting point for a RESTful service utilizing ExpressJS
Branch: master
Clone or download
anthonyg-ips Merge pull request #3 from ips-yes/dependabot/npm_and_yarn/server/seq…

Bump sequelize from 5.12.3 to 5.15.1 in /server
Latest commit 0fb0f02 Oct 30, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
server Bump sequelize from 5.12.3 to 5.15.1 in /server Oct 30, 2019
.gitignore Minor Readme fixes for adding path, changing parameters to camelcase Aug 27, 2019


An architecturally sound starting point for a RESTful service utilizing expressjs, sequelize, and PostgreSQL.

sequelize sequelize sequelize

  • bcrypt: One way encryption of passwords
  • joi: validates the request objects before route entry
  • passport: authentication and authorization middleware
  • winston: Logging framework

Class Organization

  • Route: An initial entry to the web service corresponding to HTTP methods (POST, GET, PUT, etc.). The route listens for incoming request and routes them to the lower layers.

  • Controller: Contains business logic to be performed to fulfill the given requests. An example might be calling various database tables and aggregating their data to be returned to the client.

  • Repository: The sole purpose is to communicate with the database.

  • Validation: JOI json schema for validation of request parameters

Project Structure

Project favores the division of classes by feature instead of by class type. Consider the features/users directory.

  • UserController
  • UserRepository
  • UserRoute
  • UserValidation

Additional directories

  • utils: global classes and functions.
  • config: global configurations.
  • middleware: global middleware.

Sample Routes

The base path can be found in the config/dev.json

POST /users/

This route will create a user. Note that when creating the first user you'll need to remove the authentication middleware temporarily

required body params

  • email : string
  • password : string 8 characters, One Uppercase, One Lowercase, One number, One special char
  • userTypeId : int

POST /users/login

This route will attempt to login the given user. It will return a session token which must then be provided for authorization on requests

required body params

  • email : string
  • password: string

GET /users/

This route will get the user with the associated ID.

required query params

  • id : int
You can’t perform that action at this time.