Coder Social home page Coder Social logo

nmhieudut / express-base-sequelize Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dangphu2412/express-base-sequelize

1.0 0.0 0.0 149 KB

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.

Structure

  • Each api must have validation
  • Inject other module via service not repository.

Reference

SOLID

express-base-sequelize's People

Contributors

dangphu2412 avatar

Stargazers

Hieu Nguyen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.