Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/midrissi/krypty
- Owner: midrissi
- License: mit
- Created: 2020-06-08T20:42:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T18:56:52.000Z (about 2 years ago)
- Last Synced: 2024-10-30T15:21:12.938Z (2 months ago)
- Topics: cache, nodejs, redis
- Language: JavaScript
- Size: 1.3 MB
- Stars: 15
- Watchers: 3
- Forks: 1
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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