Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does Express.js do in the MEAN stack?

I have recently have gotten into AngularJS and I love it. For an upcoming project I am looking to use the MEAN stack (MongoDB, Express, Angular, Node). I'm pretty familiar with Angular and I have a modest understanding of the purposes of MongoDB and Node in the stack. However, I don't really understand what the purpose of Express.js is. Is it essential to the MEAN stack? What would you compare it to in a traditional MySQL, PHP, javascript app? What does it do that the other three components can't do?

Also, if someone wants to give their own take on how the four parts of the stack work together, that'd be great.

like image 517
NicolasMoise Avatar asked Oct 16 '13 18:10

NicolasMoise


People also ask

What does ExpressJS do in a Mern stack?

Express. js is a server-side application framework that wraps HTTP requests and responses, and makes it easy to map URLs to server-side functions. React. js is a front end JavaScript framework for building interactive user interfaces in HTML, and communicating with a remote server.

Why do we use ExpressJS?

ExpressJS is a prebuilt NodeJS framework that can help you in creating server-side web applications faster and smarter. Simplicity, minimalism, flexibility, scalability are some of its characteristics and since it is made in NodeJS itself, it inherited its performance as well.

What does the Express () do?

Express provides methods to specify what function is called for a particular HTTP verb ( GET , POST , SET , etc.) and URL pattern ("Route"), and methods to specify what template ("view") engine is used, where template files are located, and what template to use to render a response.

What is Node JS in mean stack?

Node. js is used to write the Server Side Code in Javascript. One of the most important points is that it runs the JavaScript code outside the Browser. It is cross-platform and Open Source.


1 Answers

  • MongoDB = database
  • Express.js = back-end web framework
  • Angular = front-end framework
  • Node = back-end platform / web framework

Basically, what Express does is that it enables you to easily create web applications by providing a slightly simpler interface for creating your request endpoints, handling cookies, etc. than vanilla Node. You could drop it out of the equation, but then you'd have to do a lot more work in whipping up your web-application. Node itself could do everything express is doing (express is implemented with node), but express just wraps it up in a nicer package.

I would compare Express to some PHP web framework in the stack you describe, something like slim.

like image 59
jakee Avatar answered Sep 23 '22 01:09

jakee