krypty
v0.1.2
Published
A library helping to prevent running consuming APIs multiple times
Downloads
3
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:
:rocket: Using the library, the response is much better:
See it in action:
: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.
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