UNPKG

@rxap/n8n-utilities

Version:

This package provides utility functions and classes for n8n nodes, including custom authentication methods (Bearer Auth, Oauth2 Proxy Auth, Base URL), a decorator for capturing execution errors, and base classes for creating nodes from OpenAPI specificati

22 lines 806 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cached = cached; const tslib_1 = require("tslib"); const node_crypto_1 = require("node:crypto"); function cached(_a, fn_1) { return tslib_1.__awaiter(this, arguments, void 0, function* ({ disabled, keyv, ttl }, fn, ...args) { if (disabled || !keyv) { return fn(...args); } const key = (0, node_crypto_1.createHash)('sha256').update(JSON.stringify(args)).digest('hex'); if (yield keyv.has(key)) { const cached = (yield keyv.get(key)); cached['__cache__'] = key; return cached; } const result = yield fn(...args); yield keyv.set(key, result, ttl); return result; }); } //# sourceMappingURL=cached.js.map