Adavnce nodeJS code practices and tools. This repository provides links to useful tools and concepts needed to get your app production ready.
-
routes for each resource
-
controller to seperate out logic from routes. each route map to controller
-
middleware
- functions that access has to req/res cycle and runs wihtin that cycle. It can set values before request goes to any of the routes. next defines the move to next middlware.
-
morgan for logger
-
colors for advance console logging
-
to use req.body we need a body parser.
-
every mongoose method returns a promise
-
findbyidandupdate does not do validation. we have to mention explicitly if updated data is needed.
-
customised error handler
- Anyway, bodyParser.json() returns a function, and when that function is passed into app.use, it acts just like any other middleware. It may be helpful to think about it like this: var cb = bodyParser.json(); app.use(cb);
- Body Parser: https://medium.com/@adamzerner/how-bodyparser-works-247897a93b90
- Colors: https://nodejs.org/en/knowledge/command-line/how-to-get-colors-on-the-command-line/
- Slug: https://medium.com/@thiscodeworks.com/implementing-url-slugs-on-express-node-js-5f5890431dea
- express-fileupload:
- Geocoder: https://www.npmjs.com/package/node-geocoder
- json web token: https://json.io
- cookie parser: https://www.npmjs.com/package/cookie-parser
- Agenda.js: https://medium.com/hacktive-devs/nodejs-scheduling-tasks-agenda-js-4b6824f9457e
- Callback: http://javascriptissexy.com/understand-javascript-callback-functions-and-use-them/
- let vs const vs var : http://javascriptissexy.com/understanding-es2015-in-depth-part-1-block-scope-with-let-and-const/
- spread operator
- AWS SES Integration: https://medium.com/@maciej.lisowski.elk/nodejs-and-amazon-ses-how-to-send-emails-from-your-application-5c24b1f9b67b
- Nodemailer: https://nodemailer.com/about/
- Mail trap: https://www.mailtrap.io
- https://medium.com/@nem25/setting-up-your-own-bulk-mail-server-using-sendy-and-aws-20d05ee01362
- queries: https://mongoosejs.com/docs/queries.html
- virtuals: https://mongoosejs.com/docs/guide.html#virtuals
- Mongo Charts: https://www.mongodb.com/blog/post/mongodb-charts-gets-embeddable
- Mongo Statics: https://stackoverflow.com/questions/39708841/what-is-the-use-of-mongoose-methods-and-statics, https://www.khanacademy.org/computing/computer-programming/programming-natural-simulations/programming-vectors/a/static-functions-vs-instance-methods
- Sql injection:
- Security headers using helmet: https://helmetjs.github.io/
- XSS: Avoid any html tags inside any text. https://www.npmjs.com/package/xss-clean
- Rate-limit: https://github.com/nfriedly/express-rate-limit
- protect against HTTP Parameter Pollution attacks: https://github.com/analog-nico/hpp
- cors: https://github.com/expressjs/cors
- ssl: Detailed thoughts on https