node-api-starter
v1.0.2
Published
Babel 7 Node API Starter
Downloads
13
Readme
Babel 7 Node API Starter base
- Babel 7 so you can use all the babel goodness you want on your server
- Nodemon for your development reloading bliss
- Morgan for your logging needs
- Helmet to help secure your application
- Jest for testing & coverage
- Prettier and ESLint for formatting and linting
- Husky for git hooks
Running your API
npm startand start coding- Save your files and the server will automatically reload
Running your tests
Unit Tests
npm test- See Jest docs for how to write your tests
- See
/src/main/controller.test.jsfor an example of a test
Coverage
npm run coverage
Deploying your API
npm run buildto create a build of your codenpm run serveto serve the code up from your/builddirectory
Logs
- Logs use
morganfor formatting the messages - All logs will be output into the
/logsdirectory - Rotation policy on both
app.loganderror.logis 10Mb and/or 1 day - 4xx & 5xx errors will be placed into your
error.log - All traffic will be recorded in
app.log
Configuring logs
/src/express/logs.jscontains the logging setup- You can add a new rotation policy (see rotating-file-stream for options)
- You can also add another express middleware for writing new/different logs
Routing
- Any
routes.jsfile within the/srcdirectory will automatically be picked up on application load - See
/src/main/routes.jsfor an example
