krypty

A library helping to prevent running consuming APIs multiple times

Usage no npm install needed!

<script type="module">
  import krypty from 'https://cdn.skypack.dev/krypty';
</script>

README

Krypty

Krypty is an express middleware helping you to prevent running consuming APIs multiple times.

:snail: Without using the library, the response time will be like:

Without krypty

:rocket: Using the library, the response is much better:

With krypty

See it in action:

Krypty - Memory Strategy

:rocket::rocket: Using Redis strategy is even better. In the demo bellow, we start an express app in two different ports (3000 and 3001), then we launch a request that takes 10 seconds multiple times.

Krypty - Memory Strategy

Install

npm install --save krypty

How to use

const krypty = require('krypty');
const express = require('express');
const app = express();

app.use('/long', [
  krypty.memory(),
  (req, res) => setTimeout(() => res.json(true), 5000),
]);

app.listen(process.env.PORT || 3000);

Using Redis Strategy

const { redis } = require('krypty');
const express = require('express');
const { createClient } = require('redis');

const app = express();

app.use('/long', [
  krypty.redis(),
  (req, res) => setTimeout(() => res.json(true), 5000),
]);

app.listen(process.env.PORT || 3000);

License

MIT © Mohamed IDRISSI