MERN Backend Modules - 4
Tags: tutorial, productivity, webdev, beginners
Published: 2022-06-27 09:00:06

Hello Guyz in this blog i will be discussing some modules which we are going to use in the Backend Part.

Lets get started...

# Express.js -
* Express.js is a free and open-source web application framework for Node.js. It is used for designing and building web applications quickly and easily.
* Express.js only requires javascript, it becomes easier for programmers and developers to build web applications and API without any effort.
* You can build a single page, multi-page, or hybrid web applications using Express.js. Express.js is lightweight and helps to organize web applications on the server-side into a more organized MVC architecture.

### Installation 
```
npm i express
```

# Mongoose -
* Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node.js. It manages relationships between data, provides schema validation, and is used to translate between objects in code and the representation of those objects in MongoDB.
* It also made easy to make a connection with mongodb with one line of code.

### Installation - 
```
npm i mongoose
```

# CORS -
* CORS stands for Cross-Origin Resource Sharing. It allows us to relax the security applied to an API. This is done by bypassing the Access-Control-Allow-Origin headers, which specify which origins can access the API.

* How CORS works?
An API is a set procedure for two programs to communicate. This means that API resources are consumed by other clients and servers.

Here are two scenarios:
Case 1 - The client and the server have the same origin. In this example, accessing resources will be successful. You’re trying to access resources on your server, and the same server handles the request.
Case 2 - The client and server have a different origin from each other, i.e., accessing resources from a different server. In this case, trying to make a request to a resource on the other server will fail.

* This is a security concern for the browser. CORS comes into play to disable this mechanism and allow access to these resources. It will add a response header access-control-allow-origins and specify which origins are permitted. CORS ensures that we are sending the right headers.

### Installation - 
```
npm i cors
```

# Body-Parser -
* Body-parser is the Node.js body parsing middleware. It is responsible for parsing the incoming request bodies in a middleware before you handle it.
* Express body-parser is an npm library used to process data sent through an HTTP request body. It exposes four express middlewares for parsing text, JSON, url-encoded and raw data set through an HTTP request body. These middlewares are functions that process incoming requests before they reach the target controller.

### Installation -
```
npm i body-parser
```

# Nodemon - 
* nodemon is a tool that helps develop Node. js based applications by automatically restarting the node application when file changes in the directory are detected. nodemon does not require any additional changes to your code or method of development.

### Installation - 
```
npm i nodemon
```

NOTE - I HAVE ALREADY SHOW HOW TO SETUP NODEMON IN MY FIRST BLOG OF THIS SERIES 
https://dev.to/shubhamtiwari909/mern-crud-setup-148a

## You can install all these modules together with the command - 
```
npm i express mongoose cors body-parser nodemon
```

Thats it for this post, i will continue this series in the next blog where i will be creating a form to sent the data to our backend with some validations..
THANK YOU FOR READING THIS POST AND IF YOU FIND ANY MISTAKE OR WANTS TO GIVE ANY SUGGESTION , PLEASE MENTION IT IN THE COMMENT SECTION.
^^You can help me by some donation at the link below Thank you👇👇 ^^
☕ --> https://www.buymeacoffee.com/waaduheck <--

Also check these posts as well
https://dev.to/shubhamtiwari909/react-hooks-usecontext-1ml2

https://dev.to/shubhamtiwari909/redux-combinereducers-mk0

https://dev.to/shubhamtiwari909/introduction-to-tailwind-best-css-framework-1gdj