/nodejs-express-mvc

NodeJS MVC using express, knexjs, and objection orm.

Primary LanguageJavaScript

Node.js MVC

Simple Node.js MVC architecture with class object implementation using babel.

Design Pattern

  • Repository Design Pattern

Requirement

This boilerplate uses latest version of Node/NPM. i.e. node v12 and npm v6.9.

Tech

Installation

  1. Clone the repository
  2. Copy .env.example to .env
$ cp .env.example .env
  1. Update the information in .env file with your information such as database credentials etc.
  2. Install npm packages. I recommend to use yarn.
$ yarn

or,

$ npm install
  1. Now, start server with following commands.
$ yarn start

Other important commands

  1. Create database migration file
$ yarn make:migration create_users_table
  1. Run Migrations
$ yarn migrate
  1. Rollback migration
$ yarn migrate:rollback
  1. Create database seeder file
$ yarn make:seed UsersTableSeeder
  1. Run seeders
$ yarn db:seed

Ready for production

To deploy in production, first build app with following command

$ yarn build

After building app, deploy build directory and run like any other node app.

Support

If you faced any issue with this boilerplate create an issue. Or if you manage to improve it, send pull request.