This commit is contained in:
Rizky 2024-12-24 13:55:43 +07:00
parent 9a4789200a
commit a750f602a6
3 changed files with 20 additions and 3 deletions

View File

@ -1,5 +1,7 @@
import type { PrasiHttpHandler, PrasiServer } from "typings/server"; import type { PrasiHttpHandler, PrasiServer } from "typings/server";
export const handleHttp: PrasiHttpHandler = async () => { export const createHttpHandler: () => PrasiHttpHandler = () => {
return new Response(); return async () => {
return new Response("wuwu");
};
}; };

View File

@ -1,3 +1,5 @@
import { createHttpHandler } from "./handler/http-handler";
import { createWsHandler } from "./handler/ws-handler";
import { prasi } from "./prasi-var"; import { prasi } from "./prasi-var";
export const init = async ({ export const init = async ({
@ -17,4 +19,9 @@ export const init = async ({
if (prasi.server?.init && port) { if (prasi.server?.init && port) {
await prasi.server.init({ port }); await prasi.server.init({ port });
} }
prasi.handler.http = createHttpHandler();
prasi.handler.ws = createWsHandler();
}; };
prasi;

View File

@ -1,4 +1,8 @@
import type { PrasiServer } from "typings/server"; import type {
PrasiHttpHandler,
PrasiServer,
PrasiWsHandler,
} from "typings/server";
import { type SiteConfig } from "utils/config"; import { type SiteConfig } from "utils/config";
if (!(globalThis as any).prasi) { if (!(globalThis as any).prasi) {
@ -9,6 +13,10 @@ export const prasi = (globalThis as any).prasi as unknown as {
dir: { root: string }; dir: { root: string };
static_cache: any; static_cache: any;
server?: PrasiServer; server?: PrasiServer;
handler: {
http: PrasiHttpHandler;
ws: PrasiWsHandler;
};
site?: { site?: {
db?: SiteConfig["db"]; db?: SiteConfig["db"];
layouts: { layouts: {