1.2.0 • Published 1 year ago

@oneorigin/cached-credential v1.2.0

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
1 year ago

cached-credential

cached-credential is a module for NodeJS/ExpressJS written in pure Javascript. This module can be used to cache credentials so retrieval is faster.

Installation

npm i @oneorigin/cached-credential

Usage

const CachedCredential = require('@oneorigin/cached-credential');

const credential = new CachedCredential({
  secretCredentailName: {
    expiry: secretExpiry,
    source: helper.getToken
  }
});

credential.get('secretCredentialName');

credential.isExpired('secretCredentialName');

Description

  • expiry : Expiration time of the credentials in seconds.
  • source : A helper function that fetches the credentials from the source location.
  • get() : Get the credentials from the source location if expired or from cache if not expired.
  • isExpired() : Return a boolean indicating if the credentials are expired or not.