express-middleware-slooow

0.0.0 • Public • Published

express-middleware-slooow

Build Status

Express.js middleware to mimic slow loading HTTP resources.

Usage

Install Express

npm install express

Install slooow

npm install express-middleware-slooow

Create an Express server

var express = require('express');
var port = 3000;
var server = express();
var slooow = require('express-middleware-slooow');

// Mount slooow on /slooow
server.use('/slooow', slooow);

server.listen(port);

In the example slooow is mounted on /slooow, meaning it will be executed for any type of HTTP request to /slooow. If you want to execute it for every request to the server then you should use it without a mount path.

Point resource links to server

Scheme

http://localhost:3000/slooow?ttfb=${ttfb}&url=${url}

Examples

Example 1: Request jquery.js from cdnjs with a TTFB of 2 seconds.

<script src="http://localhost:3000/slooow?ttfb=2&url=http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.js"></script>

Example 2: Request normalize.css from cdnjs with a TTFB of 0.5 seconds.

<link href="http://localhost:3000/slooow?ttfb=.5&url=http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css" rel="stylesheet">

Example 3: Request image.jpg from localhost:3000 with a TTFB of 1.25 seconds.

<img src="http://localhost:3000/slooow?ttfb=1.25&url=http://localhost:3000/image.jpg">

Example 4: Request image.png from localhost:3000 with a TTFB of 2 seconds.

.selector {
    background-image: url('http://localhost:3000/slooow?ttfb=2&url=http://localhost:3000/image.png');
}

Testing

npm install
npm test

Package Sidebar

Install

npm i express-middleware-slooow

Weekly Downloads

1

Version

0.0.0

License

MIT

Last publish

Collaborators

  • stevenbenisek