The order in which middleware are defined in a file tells the order in which they would be applied to an incoming request.
To install a middleware :: npm install middleware-name –save
1) morgan for logging.
2) express.static for serving static content
app.use(express.static(__dirname + ‘/public’));
Static files requested can only be sent using the GET request not the POST request. Create a folder named ‘public’ with the static content inside.
3) body-parser for parsing the json or other content in body of request
eg. var bodyParser = require(‘body-parser’);
4) Express Generator: Quick scaffolding tool to generate an Express application skeleton.
npm install express-generator -g
Go into the folder in which you want to create the node express application skeleton:
express app-name (generates the application skeleton).
Now install the dependencies from package.json
Now you can start the express server with :
Express Generator: http://expressjs.com/en/starter/generator.html