A boilerplate for building a NodeJS API server. Use it as a template project when you want to start a new project.
- restify is a smallish framework, similar to express for building REST APIs.
- mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.
- config organizes hierarchical configurations for your app deployments.
- bunyan is a JSON logging library for node.js services
- pm2 is a production process manager for Node.js applications with a built-in load balancer
- supertest is a library for testing node.js HTTP servers using a fluent API
- gulp Automate and enhance your workflow
- gulp-jshint is a tool that helps to detect errors and potential problems in your JavaScript code
- gulp-jscs is a code style linter for programmatically enforcing your style guide
- gulp-cucumber gulp task for running cucumber.js features
- gulp-bump bump npm versions with Gulp
- gulp-git is a git plugin for gulp
- gulp-tag-version tag git repository with current package version
- pre-commit A better pre-commit hook for git
$ npm start
$ npm status
$ npm stop
All application logs (requests, responses, traces and mongodb accesses) are stored in a file.
The log file path is ~/.pm2/logs/[name]-[id].log
.
$ npm run logs
Show errors in http requests:
$ tail -f ~/.pm2/logs/[name]-[id].log | node_modules/bunyan/bin/bunyan -c 'this.res && this.res.statusCode >= 500'
The pre-commit
doesn't allow you to commit files with invalid format.
We use the airbnb style guide.
And the tests are going to be checked before the git commit.
$ node src/server.js
Read the logs better using bunyan:
$ node src/server.js | ./node_modules/bunyan/bin/bunyan
$ npm test
Versioning Used: Semantic
- major: version when you make incompatible API changes, e.g. 1.0.0
- minor: version when you add functionality in a backwards-compatible manner, e.g. 0.1.0
- patch: version when you make backwards-compatible bug fixes, e.g. 0.0.1
This command increases the package version, commits changes and create a tag for the new version.
$ npm run patch
This command increases the package version, commits changes and create a tag for the new version.
$ npm run minor
This command increases the package version, commits changes and create a tag for the new version.
$ npm run major