Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm's 300,000 packages pre-installed, including connect-settimeout with all npm packages installed. Try it out:

var connectSettimeout = require("connect-settimeout")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

connect-settimeout v0.0.3

a connect middleware that runs a provided function if a request lasts longer than a given duration

connect-settimeout

a connect middleware that runs a provided function if a request lasts longer than a given duration

Build Status Coverage Status

NPM

Setup:

Add this middleware to your connect or express app like this:

var connectSetTimeout = require('connect-settimeout');
app.use(connectSetTimeout(function(req, res){
  // do whatever you want with the slow request, eg:
  console.error("There was a slow response at ", req.method, req.url);
}, 10000));  // 10 seconds, specified in milliseconds
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free