The newest ExpressJS doesn't inherit from http.Server anymore.
If I try to listen on the upgrade
event, the server will answer with a 404 Not Found
.
Current [simplified] code is:
app.on('upgrade', function(req, socket, head) { /* ... */ });
If I try to search for the answer on Google, I'll only find links related to "3.0 -> 4.0 express upgrade", not HTTP upgrade.
As requested by @jfriend00 , my express initialization [simplified] code:
app = express.createServer();
app.listen(self.port, self.ipaddress);
In order to view your project, you can send information from your Express server through a GET request, an HTTP method. In index. js , append .
express : Express is a Node. js framework for building web applications and backend APIs. spdy : spdy is an express compatible module that creates HTTP/2 enabled servers in Node. js.
Express is made on top of the HTTP module. HTTP module provides various tools (functions) to do things for networking like making a server, client, etc. Express along with what HTTP does provide many more functions in order to make development easy.
The Express philosophy is to provide small, robust tooling for HTTP servers, making it a great solution for single page applications, web sites, hybrids, or public HTTP APIs. Navigate to the port 3000 as previously set in the server.
Since my comment seemed to work for you, I'll put it in an answer.
express.createServer()
has been deprecated for a long time and removed from Express 4. You would create the app object in Express 4 with:
var app = express()
The http server object is then returned from
var server = app.listen(...)
If you need direct access to the http server object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With