@httpc/kit
Version:
httpc toolbox for building function-based API with minimal code and end-to-end type safety
21 lines (20 loc) • 771 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.cache = void 0;
const assert_1 = __importDefault(require("assert"));
const tsyringe_1 = require("tsyringe");
const di_1 = require("../di");
function cache(key, options) {
return (0, tsyringe_1.injectWithTransform)((0, di_1.KEY)("ICachingService"), GetCacheTransform, key, options);
}
exports.cache = cache;
class GetCacheTransform {
transform(service, key, options) {
const cache = service.getCache(key, options);
(0, assert_1.default)(cache, `No cache for key '${key}'`);
return cache;
}
}