This is a startpack for a nodejs server running on Koa framework.
- Logging
- morgan log into a file
- debug and error log functions log to console during development
- No log to console in production
- Cors
- Helmet
-
clone Repo Nodejs
-
Run
npm i
-
Install gulp globally with
npm install -g gulp
-
Create a ".env" file in the project root folder to change the following from the default:
- NODE_ENV -- default is "dev"
- server port -- default is 5000 and save as PORT in .env
- color, and level for debug, error and http, and server using camelCase -- debugColor, debugLevel.
-
Manage options for cors, helmet and morgan in their various file in src/config/middleware
-
run
npm run server
to gulp and run server; -
run
npm run lint
to check for errors
- Use the HTTPError class to create Http error when handling error