.gitignore + untrack build outputs (node_modules, dist) — the nested repo needs its own ignore rules; the pipeline rebuilds anyway
deploy / build-and-publish (push) Successful in 45s
deploy / build-and-publish (push) Successful in 45s
This commit is contained in:
-74
@@ -1,74 +0,0 @@
|
||||
import {
|
||||
defineDriver,
|
||||
normalizeKey,
|
||||
joinKeys,
|
||||
encodeURLSegment
|
||||
} from "./utils/index.mjs";
|
||||
const DRIVER_NAME = "vercel-runtime-cache";
|
||||
export default defineDriver((opts) => {
|
||||
const base = normalizeKey(opts?.base);
|
||||
const r = (key) => encodeURLSegment(DRIVER_NAME, joinKeys(base, key), key).replace(
|
||||
/%3A/g,
|
||||
":"
|
||||
);
|
||||
let _fallback;
|
||||
const getClient = () => getContext()?.cache || (_fallback ??= getFallbackCache());
|
||||
return {
|
||||
name: DRIVER_NAME,
|
||||
getInstance: getClient,
|
||||
async hasItem(key) {
|
||||
const value = await getClient().get(r(key));
|
||||
return value !== void 0 && value !== null;
|
||||
},
|
||||
async getItem(key) {
|
||||
const value = await getClient().get(r(key));
|
||||
return value === void 0 ? null : value;
|
||||
},
|
||||
async setItem(key, value, tOptions) {
|
||||
const ttl = tOptions?.ttl ?? opts?.ttl;
|
||||
const tags = [...tOptions?.tags || [], ...opts?.tags || []].filter(
|
||||
Boolean
|
||||
);
|
||||
await getClient().set(r(key), value, {
|
||||
ttl,
|
||||
tags
|
||||
});
|
||||
},
|
||||
async removeItem(key) {
|
||||
await getClient().delete(r(key));
|
||||
},
|
||||
async getKeys(_base) {
|
||||
return [];
|
||||
},
|
||||
async clear(_base) {
|
||||
if (opts?.tags && opts.tags.length > 0) {
|
||||
await getClient().expireTag(opts.tags);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
const SYMBOL_FOR_REQ_CONTEXT = /* @__PURE__ */ Symbol.for(
|
||||
"@vercel/request-context"
|
||||
);
|
||||
function getContext() {
|
||||
const fromSymbol = globalThis;
|
||||
return fromSymbol[SYMBOL_FOR_REQ_CONTEXT]?.get?.() ?? {};
|
||||
}
|
||||
function getFallbackCache() {
|
||||
const cache = tryRequireVCFunctions()?.getCache?.({
|
||||
keyHashFunction: (key) => key,
|
||||
namespaceSeparator: ":"
|
||||
});
|
||||
if (!cache) {
|
||||
throw new Error("Runtime cache is not available!");
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
let _vcFunctionsLib;
|
||||
function tryRequireVCFunctions() {
|
||||
if (!_vcFunctionsLib) {
|
||||
const { createRequire } = globalThis.process?.getBuiltinModule?.("node:module") || {};
|
||||
_vcFunctionsLib = createRequire?.(import.meta.url)("@vercel/functions");
|
||||
}
|
||||
return _vcFunctionsLib;
|
||||
}
|
||||
Reference in New Issue
Block a user