An Express API starter using Monk to communicate with MongoDB.
Default:
- body-parser
- parse incoming body requests
- cors
- middleware for enabling cross origin resource sharing
- dotenv
- module for loading .env variables
- express
- server framework
- helmet
- http header security
- monk
- tiny mongodb communication layer
- morgan
- request logger middleware
Dev dependencies:
/config
connection.js -- set the db and port values using dotenv
/controllers
posts.js -- logic for handling db with monk
/middleware
404_handler.js -- 404 response handler
error_handler.js -- general error handler
/routes
posts.js -- assign endpoints
/test
app.test.js -- example testing with mocha and supertest
env.sample -- example of environment variables
app.js -- main express app
package.json -- required dependencies
-
Change .env.sample to .env and edit variables
-
NPM, Node, MongoDB
-
Global dependencies
npm install nodemon mocha -g
Install dependencies
npm install
Run application
npm run start
Run application in development mode
npm run dev
Run tests
npm run test