What's the difference between creating a server using http module and creating a server using express framework in node js? Thanks.
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Axios OPTIONS instead of POST Request. Express Res
- google-drive can't get push notifications
- Failed at the electron@1.8.2 postinstall script
- How to reimport module with ES6 import
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
- fetch: Getting cookies from fetch response
Express uses the http module under the hood,
app.listen()
returns an instance of http. You would usehttps.createServer
if you needed to serve your app using HTTPS, asapp.listen
only uses the http module.Here's the source for
app.listen
so you can see the similarities.:Ultimately, express uses node's http api behind the scenes.
express framework
The express framework provides an abstraction layer above the vanilla http module to make handling web traffic and APIs a little easier. There's also tons of middleware available for express (and express-like) frameworks to complete common tasks such as: CORS, XSRF, POST parsing, cookies etc.
http api
The http api is very simple and is used to to setup and manage incoming/outgoing ,HTTP connections. Node does most of the heavy lifting here but it does provide things you'll commonly see throughout most node web framework such as:
request
/response
objects etc.