mirror of https://github.com/186526/handlers.js
21 lines
506 B
TypeScript
21 lines
506 B
TypeScript
import { SWPlatformAdapter } from "./serviceworker";
|
|
import { platformAdapater } from "./index";
|
|
|
|
export class BunPlatformAdapter<T = any, K = any>
|
|
extends SWPlatformAdapter<T, K>
|
|
implements platformAdapater<T, K>
|
|
{
|
|
async listen(port: number): Promise<void> {
|
|
Bun.serve({
|
|
fetch: async (request: Request): Promise<Response> => {
|
|
return await this.handleResponse(
|
|
await this.handleRequest(request).then((request) =>
|
|
this.router.respond(request)
|
|
)
|
|
);
|
|
},
|
|
port,
|
|
});
|
|
}
|
|
}
|