Till
08/13/2021, 5:17 PMHardAtWork
08/13/2021, 5:21 PMTill
08/13/2021, 5:35 PMGreg-McKeon
08/13/2021, 9:30 PMGreg-McKeon
08/13/2021, 9:32 PMkenton
08/13/2021, 9:42 PMHardAtWork
08/13/2021, 9:45 PMHardAtWork
08/13/2021, 9:46 PMErwin
08/13/2021, 9:56 PMTill
08/13/2021, 10:11 PMErwin
08/14/2021, 12:47 AMTill
08/14/2021, 12:48 AMlukeed
08/14/2021, 12:56 AMErwin
08/14/2021, 12:56 AMErwin
08/14/2021, 12:59 AMlukeed
08/14/2021, 12:59 AMts
// @cloudflare/kv-asset-handler
export function getAssetFromKV(event: FetchEvent, options?: Options): Promise<Response>;
// @cloudflare/kv-asset-handler/module
export function getAssetFromKV(req: Context, ctx: Context, options?: Options): Promise<Response>;
lukeed
08/14/2021, 12:59 AMFetchEvent
is obliterated in a module workerlukeed
08/14/2021, 12:59 AMErwin
08/14/2021, 12:59 AMlukeed
08/14/2021, 1:00 AMErwin
08/14/2021, 1:00 AMlukeed
08/14/2021, 1:07 AMts
// hacky TS utility to reassemble a FetchEvent
export function assemble(request: Request, ctx: Context): FetchEvent {
return { ...ctx, request } as FetchEvent;
}
// ...
export default {
fetch(req, env, ctx) {
if (req.url.startsWith('/static')) {
let event = assemble(req, ctx);
return getAssetFromKV(event, { ... });
}
}
};
Erwin
08/14/2021, 1:11 AMErwin
08/14/2021, 1:12 AMlukeed
08/14/2021, 1:12 AMlukeed
08/14/2021, 1:12 AMlukeed
08/14/2021, 1:13 AMErwin
08/14/2021, 1:14 AMlukeed
08/14/2021, 1:15 AMErwin
08/14/2021, 1:17 AM