I was surprised to see that it's called a framework. In the MEAN stack acronym, it replaces the web server "(A)pache" and "(I)IS" (e.g. LAMP, WISP, etc.) which are both web servers - not that that's reason to not call it a framework, but can anyone provide clarity as to why it falls into the framework camp?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
First off, Express isn't a web server. It does not have its own web server code. It can either create a standard node.js
http
server for you (when you doapp.listen()
or you can create your ownhttp
orhttps
server and pass it to Express as part of the setup.Instead, it's a "framework on top of a web server". It provides a general purpose mechanism for defining routes and middleware, error handlers and template renderers (and other things).
As an indication of this, there are tons of NPM add-ons that plug-in to your web server via the Express middleware or Express routing mechanism or rendering APIs (they plug into the framework in a standard way). This means of plugging in via a standard mechanism is, in my opinion, what makes it a framework.
So, whereas Apache is actually a web server itself, Express is a layer that runs on top of the web server that is already built into node.js.
It's certainly not a general purpose programming framework, but a very specific type of web server framework.
From WikiPedia's page for "Software framework":
Evaluating Express against this definition, it gets checkmarks for all these elements:
"applications" in this case is a node.js web server.