Template for Node.js express projects
After following the steps below a local repository explorer should show two remotes:
origin
- this is the repository where you create your project
upstream
- this is the repository where you can get template updates
Make sure always to push your changes to the origin
remote since you
will not be able to change the contents of the upstream
remote.
Create a new git
repository (e.g. on GitHub). Make sure not to select
"Initialize this repository with a README".
Clone the repository to your local machine
git clone https://github.com/USER/NEW-REPOSITORY.git
Add this template as an upstream remote to keep it up to date if we change or update things.
git remote add upstream https://github.com/gerarts/template-nodejs.git
Pull the contents of this template on your local machine.
git pull upstream master
Your local copy should be exactly the same as the template.
Push the template to your new repository and start working from there.
git push origin master
Enable your new repository on Travis-CI and enable branch protection for
the master
branch to ensure tests pass for the code in the master
branch.
express
as the environmentbody-parser
forPOST
requestscookie-parser
for cookiesmysql
for database connectionsejs
for page creation
eslint
for code style with configuration setistanbul
for coverage reportingmocha
as a testing frameworkjsdoc
for documentation generationtravis-ci
configuration set.gitignore
configuration set
start
starts the servertest
runs the testscoverage
generates a coverage reportjsdoc
generates the jsdocclean
removes the coverage report and jsdoc if they existrefresh
deletesnode_modules
and re-installs all the dependencies