This commit is contained in:
Rizky 2024-12-11 09:27:26 +00:00
parent 0d7c142e93
commit 99e5baeefb
2 changed files with 13 additions and 5 deletions

View File

@ -1,16 +1,16 @@
/// <reference types="bun-types" />
import { ServerWebSocket } from "bun";
import { useServerRouter } from "../server/server-route";
import { newSessionStore } from "./store/session-store";
import { ServerContext } from "./type";
type WS = ServerWebSocket<{ url: string }>;
type SessionServerHandler = {
export type SessionServerHandler = {
cleanup: () => Promise<void>;
handle: (
arg: ServerContext,
opt?: { cache_accept?: string }
opt?: {
rewrite?: (arg: { body: Bun.BodyInit; headers: Headers }) => Bun.BodyInit;
}
) => Promise<Response>;
};

View File

@ -71,7 +71,15 @@ export interface SessionContext<T> extends ServerContext {
export type ServerContext = {
req: Request;
server: Server;
handle: (req: Request, opt?: { cache_accept?: string }) => Promise<Response>;
handle: (
req: Request,
opt?: {
rewrite?: (arg: {
body: Bun.BodyInit;
headers: Response["headers"];
}) => Bun.BodyInit;
}
) => Promise<Response>;
mode: "dev" | "prod";
url: {
raw: URL;