UNPKG

@aziontech/opennextjs-azion

Version:
52 lines (51 loc) 1.73 kB
/** * This code was originally copied and modified from the @opennextjs/cloudflare repository. * Significant changes have been made to adapt it for use with Azion. */ /** * Defines the OpenNext configuration that targets the Azion adapter * * @param config options that enabled you to configure the application's behavior * @returns the OpenNext configuration object */ export function defineAzionConfig(config = {}) { const { incrementalCache, tagCache, queue, wrapper } = config; return { default: { override: { wrapper: resolveWrapper(wrapper), converter: "edge", proxyExternalRequest: "fetch", incrementalCache: resolveIncrementalCache(incrementalCache), tagCache: resolveTagCache(tagCache), queue: resolveQueue(queue), }, }, // node:crypto is used to compute cache keys and node:stream is used to wrapper edgeExternals: ["node:crypto", "node:stream"], }; } function resolveIncrementalCache(value = "dummy") { if (typeof value === "string") { return value; } return typeof value === "function" ? value : () => value; } function resolveTagCache(value = "dummy") { if (typeof value === "string") { return value; } return typeof value === "function" ? value : () => value; } function resolveQueue(value = "dummy") { if (typeof value === "string") { return value; } return typeof value === "function" ? value : () => value; } function resolveWrapper(value = "dummy") { if (typeof value === "string") { return value; } return typeof value === "function" ? value : () => value; }