This boilerplate is written in ES2015 and requires Node 6.x+
This is a fantastic Node/Express/Bookshelf+SQL/Role-Based Authentication boilerplate. It is designed to get you up-and-running on your own project without having to setup the basic user/role models, tasks, and more.
Git clone this repository and run npm install && npm start.
Tests are written with Mocha/Chai. A boilerplate CRUD test is included. To run them, you may run npm test.
A .env file should be created at the root of your project. If this file exists, it will look for the following key/values:
DB_HOST=localhost
DB_USR=l33tdba
DB_PW=w0rk5pac3
DB_NAME=fantasticGulp powers the base server for this boilerplate. Inside of the gulpfile.js are the following tasks:
precompile- Transformsfrontend/Javascript files using Babel for ES2015 support & places the result inside of/public/app-build.jswatch- watches for file changes infrontend/& re-runsprecompileserver- launchesnode ./bin/wwwusing Nodemon & restarts when server-side code is recompiledcreate_db_tables- creates the SQL tables specified in theconstvariables in the gulfpile. (Only ran externally viagulp create_db_tables)drop_db_tables- drops the SQL tables specified in theconstvariables in the gulpfile. (Only ran externally viagulp drop_db_tables)
bin/contains the server scriptscontrollers/contains controllers for HTTP endpointsfrontend/contains your custom client-side application code (this is transpiled to ES2015 by Babel intopublic/javascripts/app-build.jsmodels/contains all of your database & SQL specific scriptspublic/contains all folders & files exposed to/when the server is runningtest/contains Mocha/Chai unit testsviews/contain Handlebars views
This boilerplate was designed to work with SQL (sorry, NoSQL fans - just replace the models/*.js with whatever you need). Inside of models/db.js, the adapter has been specified as MySQL. Please edit this file if you need to change it.
const db = require('knex')({
client: 'mysql',
connection: {
host : process.env.DB_HOST,
user : process.env.DB_USR,
password : process.env.DB_PW,
database: process.env.DB_NAME
}
});