This is a simple starter project example for building REST APIs in Node.js using express, mongoose with es6 code without any transpiler.
For the client side is pretty much required transpiling the javaScript (ES6 to ES5) for wide range support of browsers, but when the project running on the server side with Node.js the transpiling is entirely optional because currently all ES6 features supported by Node.js.
There is no JavaScript engine yet that support natively ES6 modules not even v8 engine for crome and node.js. So currently we are unable to use the import, export module directly in node.js without using any transpiler (like: babel). instead of import, export we can use require() and module.exports. Most of other features of ES6 can use without transpiler in Node.js.
This project using together the following technologies:
- Node.js
- Express
- Mongoose
- glob Match files using the patterns. ( used in express.js file. function name: initServerRoutes)to automatically load all routes from routes directory.
- Lodash
- helmet To helps secure Express apps by setting various HTTP headers.
- cors For CORS support
- joi joi allows you to create blueprints or schemas for JavaScript objects (an object that stores information) to ensure validation of key information.
- express-validation Validate body, params, query, headers and cookies of a request (via middleware) and return a response with errors.
- gulp gulp is a toolkit for automating painful or time-consuming tasks in your development workflow
- gulp-nodemon Restart the server for real time edit using nodemon.
- winston For logging
- eslint
Clone the repository and run npm install
git clone https://github.com/shaishab/express-mongoose-api-es6-example.git
npm install
# Start server
npm start
# or
gulp dev
# Selectively set DEBUG env var to get logs
npm run-script debug
#or
cross-env DEBUG=express-mongoose-es6-api-starter:* gulp debug
The universal logging library winston is used for logging.
This project is licensed under the MIT License
- Add test using mocha