/node-es6-boilerplate

A es6 express boilerplate

Primary LanguageJavaScriptDo What The F*ck You Want To Public LicenseWTFPL

NodeJs boilerplate in ES2015

Usage: Please DO NOT use it. Take it as a reference design and craft your own masterpiece.

Yet another general NodeJs boilerplate in ES2015+.
For personal use only, licensed under WTFPL(GPL-compatible).

Purpose

  1. "import" is not supportted by Nodejs right now => Whenever u doubt the future, look for Babel(JS).
  2. Snapshot all best practices: BDD, The Twelve-Factor App

Development Environment

  • Windows 10 64bit
  • Git bash / Bash On Windows
  • VS code + ESLint extension
  • Nodejs 6.9.1(latest stable)

NOTE: Register current npm bin folder into PATH before making use of tools like babel/eslint, by executing . npm-register.sh or source npm-register.sh in your shell. If u are using BashOnWin then edit the npm-register.sh first according to instruction.

Entries

1. index

index is the entry of most of RESTful/gRPC apis.

2. admin (TBC)

admin.js is a administration Portal. By design, configuration should be done in eitehr config file or GUI.

3. ping (TBC)

A service which should perform a series of system integration tests if last result expires.
For status-checking service(pingdom) / client user to check status of service, or even HA service keeper.

Configuration references

According to The Twelve-Factor App - III. Config, configuration should strictly been separated from code. Because An app’s config is everything that is likely to vary between deploys (staging, production, developer environments, etc).

So we put all the settings to environment variables and manage them using dotenv lib.

Note: .env files should not be committed.

SERVER_PORT=3000
SERVER_HOST=localhost
SERVER_SECURE_PORT=443

Commands

See more @ package.json

  • npm run start launch node dev server.
  • . killallnode.sh kill all running node instances.
  • . setup.sh can help u copy & link original source from virtualbox shared folder to somewhere your prefer, to allow u make full use of Linux-based "node_modules/"(Must edit before Use!)

licensed