npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

express-save-replay

v2.0.4

Published

A pair of route handlers. One of them is supposed to proxy all requests to a given host then save and return the response. The other one is supposed to be able to mock and replay a "session" of responses created by the other one.

Downloads

5

Readme

express-save-replay

A pair of route handlers. One of them is supposed to proxy all requests to a given host then save and return the response. The other one is supposed to be able to mock and replay a "session" of responses created by the other one.

Shared parameters

  • baseDirForUrl: The relative location where respoonses should be saved.
  • shouldCreateReadableData: If true then responses are saved in a readable format. Sometimes it may reduce performance.
  • timeStampExtractor: An object with a modifyPath and a reset function. The modifyPath receives the url's path and can modify it in a way, to be able to handle dynamic parts of the url. A default timeStampHelper is provided aswell which considers the last part of the path as a timestamp and flags responses by their number of receival. The reset gives a chance to reset the counter of the supplied timeStampHelper but in case of an own timeStampHelper it should serve the same function. If left empty then timeStamps are handled normally.

Replay

  • maxRetries: Defines how many times can requests fail before the server should call the reset. If it isn't supplied then the server never resets the timeStampExtractor.

Record

  • remoteUrl: Defines where the requests should be forwarded.
  • prevent304: (Default: true) Modifies the header of the request so that the remote resource never answers with 304. There may be many cases where you have to turn it off due to the server not accepting such headers. In this case you must turn off caching in your browser or requester application

Possible usage

One possible usage can be seen in example.js

const record_replay = require('express-save-replay');
const express = require('express');

const app = express();

//in case of recording use this (should be handled from args)
app.use('/', record_replay.record({
  remoteUrl: "localhost:3000",
  baseDirForUrl: "test/mockServer",
  shouldCreateReadableData: true,
}))

//in case of replaying use this
app.use('/', record_replay.replay({
  baseDirForUrl: "test/mockServer",
  shouldCreateReadableData: true,
}))

app.listen(3001, function(){
  console.log('App is listening on PORT: 3000');
});