krypty

0.1.2 • Public • Published

Krypty

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

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

Without krypty

🚀 Using the library, the response is much better:

With krypty

See it in action:

Krypty - Memory Strategy

🚀🚀 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

Readme

Keywords

none

Package Sidebar

Install

npm i krypty

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

9.29 kB

Total Files

6

Last publish

Collaborators

  • idrissi