Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/midrissi/krypty

Prevent running consuming APIs multiple times
https://github.com/midrissi/krypty

cache nodejs redis

Last synced: about 1 month ago
JSON representation

Prevent running consuming APIs multiple times

Awesome Lists containing this project

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](./screenshots/without-krypty.png)

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

![With krypty](./screenshots/with-krypty.png)

See it in action:

[![Krypty - Memory Strategy](https://img.youtube.com/vi/huUO9Qkyz9k/0.jpg)](https://www.youtube.com/watch?v=huUO9Qkyz9k)

: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](https://img.youtube.com/vi/pQUDQ3_LUUg/0.jpg)](https://www.youtube.com/watch?v=pQUDQ3_LUUg)

## Install

```shell
npm install --save krypty
```

## How to use

```javascript
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

```javascript
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