Base express ES6 with Sequelize config with MVC. Intergrated authen and authorize basic
JavaScript 99.50%Shell 0.50%
express-base-sequelize's Introduction
Start your project
First you need to npm install or yarn install
Check .env.example then create new file .env then fill it up.
If connection to pg is available go to next step.
Run yarn migrate:latest to migrate the latest files and run yarn seed:run if you want to have seeds to test.
Finally, run yarn dev or npm run dev
Please make sure your have the right version of nodejs and postgresql
Convention:
Design pattern:
Singleton module:
Each module may contain: controller, service and repository. These are default singleton if we export it as a alias via new instance. Example: export const AuthController = new Controller();
Repository pattern:
Each repository (if exist) will be injected by a model from Sequelize model via constructor
Allow to redefine some needed function related to query
Liskov Substitution Principle
Define class parent and children extends from that not change the right ability of parent class
Open/closed principle
Write code for easy opening and hard to rewrite, easy to reuse. We should write new class to open new function not rewrite old class.
Code convention
Single colon
Use export const instead of export default for easy knowing alias import
Core directory must have index.js to export all sub module dir.
Scope should be define in common/constants/scopes first then use name in model define scopes.