Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Skipped
17 lines
532 B
Plaintext
17 lines
532 B
Plaintext
//#region src/adapter/service-worker/handler.ts
|
|
/**
|
|
* Adapter for Service Worker
|
|
* @deprecated `hono/service-worker` will be removed in v5. Install `@hono/service-worker` and import from there instead.
|
|
*/
|
|
const handle = (app, opts = { fetch: globalThis.fetch.bind(globalThis) }) => {
|
|
return (evt) => {
|
|
evt.respondWith((async () => {
|
|
const res = await app.fetch(evt.request, {}, evt);
|
|
if (opts.fetch && res.status === 404) return await opts.fetch(evt.request);
|
|
return res;
|
|
})());
|
|
};
|
|
};
|
|
//#endregion
|
|
export { handle };
|