Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

connect-pause

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-pause

Connect/Express middleware to simulate latency for debugging

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
224K
decreased by-6.47%
Maintainers
1
Weekly downloads
 
Created

What is connect-pause?

The connect-pause npm package is a middleware for Connect/Express that allows you to introduce a delay in the processing of HTTP requests. This can be useful for simulating network latency or testing how your application behaves under slow network conditions.

What are connect-pause's main functionalities?

Introduce a fixed delay

This feature allows you to introduce a fixed delay (in milliseconds) for all incoming HTTP requests. In this example, a 2-second delay is added to all requests.

const express = require('express');
const pause = require('connect-pause');

const app = express();

// Introduce a 2-second delay for all requests
app.use(pause(2000));

app.get('/', (req, res) => {
  res.send('Hello, world!');
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

Conditional delay

This feature allows you to introduce a delay conditionally, for example, only for specific routes. In this example, a 3-second delay is added only to requests to the '/slow' route.

const express = require('express');
const pause = require('connect-pause');

const app = express();

// Introduce a delay only for specific routes
app.use('/slow', pause(3000));

app.get('/slow', (req, res) => {
  res.send('This response is delayed by 3 seconds');
});

app.get('/fast', (req, res) => {
  res.send('This response is fast');
});

app.listen(3000, () => {
  console.log('Server is running on port 3000');
});

Other packages similar to connect-pause

Keywords

FAQs

Package last updated on 22 May 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc