How to use the cachios.cache function in cachios

To help you get started, we’ve selected a few cachios examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cheapsteak / npmcharts.com / packages / server / routes / api.js View on Github external
const express = require('express');
const cachios = require('cachios');
const LRU = require('lru-cache');

cachios.cache = LRU({
  max: 500,
  maxAge: 60 * 1000,
});

const router = express.Router();

// Can't use http-proxy-middleware because it triggers
// Cloudflare's Error 1000 DNS points to prohibited IP
router.get('/downloads*', async (req, res) => {
  const proxiedPath = `https://api.npmjs.org${req.path.replace(/^api/, '')}`;
  try {
    return res.send((await cachios.get(proxiedPath)).data);
  } catch (exception) {
    console.error(exception);
  }
});

cachios

Simple axios cache wrapper using node-cache

MIT
Latest version published 2 years ago

Package Health Score

42 / 100
Full package analysis

Popular cachios functions