Krypty is an express middleware helping you to prevent running consuming APIs multiple times.
🐌 Without using the library, the response time
will be like:
🚀 Using the library, the response is much better:
See it in action:
🚀🚀 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.
npm install --save krypty
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);
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);
MIT © Mohamed IDRISSI