Introduction To Express Middleware
Usually as developers, we feel it's a pain in the "ass" to have a seat and read about concepts, architectures or some framework or programming language related theory. But it's worth it and very necessary because opens you up to the entire concept of how the framework or language works, thus equipping the developer to write cleaner code and saves time.
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:-