What is Express JS

What is MongoDB
Express JS is a web framework which is based on the core Node JS http module and Connect components.
Those components are called middlewares.
They are the cornerstone of the framework’s philosophy, this is configuration over convention. In other words, developers are free to pick whatever libraries they need for a particular project which provides them with flexibility and high customization.

If you wrote any serious apps using only the core Node JS modules, you most likely found yourself reinventing the wheel by constantly writing the same code for the similar tasks, such as:

• Parsing of HTTP request bodies
• Parsing of cookies
• Managing sessions
• Organizing routes with a chain of if conditions based on URL paths and HTTP methods of the requests
• Determining proper response headers based on data types

Express JS usually has an entry point, known as a main file.
In that file, we perform the following steps:

1. Include third-party dependencies as well as our own modules such as controllers, utilities, helpers and models
2. Configure Express JS app settings such as the template engine and its files’ extensions
3. Define middlewares such as error handlers, static files folder, cookies and other parsers
4. Define routes
5. Connect to databases such as MongoDB, Redis or MySQL6.

Start the app when Express JS app is running, it listens to requests. Each incoming request is processed according to a defined chain of middlewares and routes starting from top to bottom. This aspect is important because it allows you to control the execution flow. For example, we can have multiple functions handling each request; and some of those functions will be in the middle (hence the namemiddleware):
1. Parse cookie information and go to the next step when done
2. Parse parameters from the URL and go to the next step when done
3. Get the information from the database based on the value of the parameter if user is authorized(cookie/session), and go to the next step if there is a match
4. Display the data and end the response

To install Express, run $ npm install -g express from your terminal.

Below is a simple Hello World program:

Hello World MongoDB

Apply Now

Join our Community

To be notified about the latest updates, offers and news from Alida School
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
© Alida School 2022. Made with ❤️ by team Alida School in London