Today we will learn about the Node.Js web application framework Express.Js.
Express.js has many features. Let’s learn about them -
- Middleware - Middleware is a function that is used to get access request and response objects.
- Faster server-side development - Express.js provides many readymade functions from Node.js it’s made easier to develop.
- Routing - Express.js provides an admiringly advanced routing mechanism.
- Templating - Template engines allow you to build dynamic content in web applications.
- Debugging - Express.js has a debugging mechanism that can find bugs easily.
- Express.js is fast & easier to learn.
- It’s easier to configure & customize.
- Huge community support.
- Supported by Google V8 Engine.
- Easy to connect with databases such as MongoDB, MySQL, etc.
- Easy to integrate with different templates.
- Allows you to define routes based on HTTP methods & URLs.
- Easy to serve static files and resources.
- Flexible middleware module.
- There are problems with the callback or event-driven nature but the last update of Node.js brings async/await that prevents this problem.
- Client request problem with middleware system.
Install with npm -
npm install express -g
First, create a directory named simpleExpress. Change to it, and run
npm init. Then install express as a dependency. In the directory create a file named index.js and write the following code.
Run the app with the following command -
$ node index.js
Then open the browser and visit “localhost:5000” to see the output.
Visit Express.js official site to read documentations and know more in details.
Thanks for reading this tutorial!