Skip to content

OurCapsule/fantastic-express-boilerplate

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fantastic Express Boilerplate (ES2015)

Build Status

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.

Getting Started

Git clone this repository and run npm install && npm start.

Tests

Tests are written with Mocha/Chai. A boilerplate CRUD test is included. To run them, you may run npm test.

Behind the Scenes

.env

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=fantastic

Gulp

Gulp powers the base server for this boilerplate. Inside of the gulpfile.js are the following tasks:

  • precompile - Transforms frontend/ Javascript files using Babel for ES2015 support & places the result inside of /public/app-build.js
  • watch - watches for file changes in frontend/ & re-runs precompile
  • server - launches node ./bin/www using Nodemon & restarts when server-side code is recompiled
  • create_db_tables - creates the SQL tables specified in the const variables in the gulfpile. (Only ran externally via gulp create_db_tables)
  • drop_db_tables - drops the SQL tables specified in the const variables in the gulpfile. (Only ran externally via gulp drop_db_tables)

Folder Structure & Organization

  • bin/ contains the server scripts
  • controllers/ contains controllers for HTTP endpoints
  • frontend/ contains your custom client-side application code (this is transpiled to ES2015 by Babel into public/javascripts/app-build.js
  • models/ contains all of your database & SQL specific scripts
  • public/ contains all folders & files exposed to / when the server is running
  • test/ contains Mocha/Chai unit tests
  • views/ contain Handlebars views

SQL Support

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
  }
});

About

A Node/Express/Bookshelf+SQL/Role-Based Authentication boilerplate.

Resources

License

Stars

1 star

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 97.3%
  • HTML 1.4%
  • CSS 1.3%