What are Mongoose Hooks
What are Mongoose Hooks. The pre and post hook are simply levels in which your code can be executed when carrying out an operation using mongoose and mongoDB. As the name implies, "pre" comes in before the operation is carried out (with the database) while "post" is executed after the operation is complete.
How to send Json response in express js
Usually, API calls or request are handled by sending a response using res.send(…). You can equally send a json response using the in-built res.json() method.
This method accepts an object and converts it to json during response.
Below is a simple express app with one route running on port 3000.
How to log Node JS http requests using morgan
Morgan is a third-party middleware or module used to log every http request information in details as customized by the developer. This is a very useful dev tool.
Morgan makes work lot more easier and flexible.
Before using Morgan, make sure Morgan has been installed or install via npm with the command:-