NodeJS Timing Out

I have a node js server using express and  I found a function I would love to try but not sure how to write the code. The code below is written using http.createServer, but since I'm using express, it's not the same format and I don't know how to write this???

How I create the server....
var express = require('/usr/lib/node_modules/express');
var app = express();
var server = require('http').Server(app);

The functionality I would like to duplicate....
http.createServer(function (req, res) {
     res.socket.once('timeout', function () {
     res.writeHead(200, {'Content-Type': 'text/plain'});
     res.end('Hello World\n');

Any help would be appreciated!
Who is Participating?
Neeraj SoniSr. ArchitectCommented:
You need to first do npm install express module in your app.

A small snippet

var express = require('express');
var app = express();
app.get('/', function (req, res) {
  res.send('Hello World!');
var server = app.listen(8888);

Open in new window

I wonder if you look at
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.