🚈 Introduction To Express JS🚈

🚈 Introduction To Express JS🚈

Express JS: A Guide for Beginners

In the startup stage🍼, it’s common to raise those common startup questions like "What is ExpressJS? Why should I use that? Is it easy to developing, maintaining, and implementing?"

In this article, we'll learn 😉about Express, the free and open-source Node.js web application framework. Built on top of the Node.js built-in http module, Express helps us set up routing and handle the request/response cycle.

What is Express.js?🤔

Let’s get the definition from express js website what they define of ExpressJs as

"Fast, unopinionated, minimalist web framework for Node.js".

According to their definition one thing is clear that it is fast in performance, next they define express as unopinionated.

What does that mean?🤯

That means with ExpressJS developers are flexible to solve complexity in several ways, there’s no specific way to follow.

Express.js is a web application framework for Node.js. It provides various features that make web application development fast and easy 🥳which otherwise takes more time using only Node.js.

Lastly express define as a minimalist web framework, which points to the simplicity and light weight of the framework😯, where Node.js is an open source JavaScript runtime environment support on various platforms like Windows, Linux, UNIX, and Mac OS X.

Install Express.js⬇️

You can install express.js using npm. The following command will install the latest version of express.js globally on your machine so that every Node.js application on your machine can use it.

npm install -g express

The following command will install the latest version of express.js locally to your project folder.

 npm install express --save

As you know, --save will update the package.json file by specifying express.js dependency.

Why do you use Express JS🤷‍♀️

I think by looking at the example given below👇, you will understand why you should use Express.js😃.

In the example, we just write a Hello world script with express.js and without express.js.

  • Without express


const http = require('http');
const server = http.createServer((req, res) => {
    res.statusCode = 200;
    res.setHeader('Content-Type', 'text/html');
    res.write('<h3>Hello World</h3>');
server.listen(3000, () => console.log('server is running'));
  • With express

Easy, simple, beauty🤠

const app = require('express')();
app.use('/',(req, res) => {
    res.send('<h3>Hello World</h3>');
app.listen(3000, () => console.log('server is running'));

Output of both

Hello World

ExpressJS Advantages🤠

ExpressJS with all those definitions like its simplicity, flexibility there’s another thing which is its biggest community.

Here’s the list of express advantages:

  1. Built-in route.

  2. Supports different view engines.

  3. Easy to create RESTful service.

  4. Easy static file serving.

  5. Makes Node.js web application development fast and easy.

  6. Easy to configure and customize.

  7. Allows you to define routes of your application based on HTTP methods and URLs.

  8. Includes various middleware modules which you can use to perform additional tasks on request and response.

Recap 🎗️

Express is a minimal and extensible framework that provides a set of common utilities for building servers and web applications😯. It's built on top of Node.js' built-in http module, but helps us accomplish the tasks of routing and handling the Request/Response cycle.

Express uses middleware to extend its capabilities with code that we either write ourselves or that has been contributed by the large community using the project.

That's all for the day hope you have liked this article🥰

See u in the next article until then keep reading😌.......

Did you find this article valuable?

Support Chhakuli Zingare by becoming a sponsor. Any amount is appreciated!