Skip to content

A basic node.js app with common libraries installed and explained

Notifications You must be signed in to change notification settings

tumblbug/nodejs-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Starter

A basic node.js app with common libraries installed and explained.

Setup

git clone https://github.com/tumblbug/nodejs-basic.git
cd nodejs-basic
npm install
npm run test

Next, you'll probably want to edit package.json to add an author, change the package name and license, etc. You can do the following to remove this project's README and delete any git history, allowing you to start fresh in a new repository. When creating a new repo for your project to live in, Github will let you know how to add your remote URL.

rm -rf .git README.md
git init
git add remote origin ...

You're now ready to start developing your app!

Scripts

npm scripts are included as follows:

  • app runs index.js in the root directory
  • debug runs app with all debugging enabled, also hides all console log messages to let you focus on debugging
  • test runs the test suite
  • test:watch automatically re-runs your test suite when code in src or test directories change
  • lint runs ESLint on all of your files
  • coverage runs Istanbul to produce a test coverage report

Linting

ESLint comes pre-installed, extending eslint-config-airbnb. Don't forget to install the appropriate plugin for your editor.

Testing

Testing is done using Mocha and Chai. chai-as-promised is included to test promise-based code. Mocks, stubs, etc. can be done using Sinon. Nock is used to test HTTP requests. Nock also disables your app from performing any HTTP requests during tests (see test/setup.js).

There are examples for each library in test/lib/api-spec.js.

Debugging

Debugging can be done with the debug library. Initialize it in each of your modules with

const debug = require('debug')('my module name');

and then simply use debug instead of console.log.

Add a DEBUG=* flag to debug all modules (same as npm run debug), or you can list certain modules that should be debugged, e.g. DEBUG=api npm run app.

Logging

Logging is done using bunyan. See index.js for examples.

Coverage

Istanbul is used to produce a test coverage report. Look inside the coverage folder after running npm run coverage to see the results.

Additional Library Recommendations

About

A basic node.js app with common libraries installed and explained

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published