New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

api-cache-mongoose

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-cache-mongoose

A NodeJS package to easily cache api calls to a MongoDB Database and update them after X minutes.

  • 1.0.4
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

api-cache-mongoose

NPM GitHub issues

What is this?*

api-cache-mongoose is an NPM package to easily cache API calls to a MongoDB database and update them after X minutes.

Install

npm install --save api-cache-mongoose

Usage

You will need to set up a mongoose connection. Check examples/database.js


var mongoose = require('mongoose');
var ApiCache = require("api-cache-mongoose")( mongoose );

ApiCache only receives two parameters, The target URL (String) and minutes between api calls (Number) default=5

app.get("/users", function(req, res){
    // ApiCache( url, minutes_between_call )
    ApiCache("https://jsonplaceholder.typicode.com/users", 30).then(function(response){
        // If the last call was less than 30 minutes ago response will load from the database
        // Else response will be fetched from the api url
        res.json(response);
    }, function(err){
        console.warn(err);
        res.json({ success : false });
    });
});

Additional Notes

  • Please report any issues here

Keywords

FAQs

Package last updated on 08 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc