Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
404 views
in Technique[技术] by (71.8m points)

node.js - Difference between a server with http.createServer and a server using express in node js

What's the difference between creating a server using http module and creating a server using express framework in node js? Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...