wip checkpoint

This commit is contained in:
Rizky 2023-12-16 17:12:02 +07:00
parent 6ddbd121cb
commit 9e0c895c37
6 changed files with 27 additions and 26 deletions

View File

@ -1,7 +1,8 @@
import hash_sum from "hash-sum";
import { fetchViaProxy } from "../proxy";
import { fetchViaProxy } from "../../../nova/vi/load/proxy";
export const dbClient = (name: string, dburl: string) => {
console.log(dburl);
return new Proxy(
{},
{

View File

@ -7,19 +7,6 @@ import { Loading } from "../../utils/ui/loading";
export default page({
url: "/ed/:site_id/:page_id",
component: ({}) => {
console.log("momoka");
setTimeout(() => {
(async () => {
console.log(
await fetch("/moka", {
method: "POST",
body: "{}",
})
);
})();
}, 2000);
return <>uwuw</>;
const p = useGlobal(EDGlobal, "EDITOR");
const w = window as any;

View File

@ -6,6 +6,7 @@ import { registerMobile } from "./render/live/logic/mobile";
import { reloadDBAPI } from "./utils/script/init-api";
import { w } from "./utils/types/general";
import { sworkerAddCache, sworkerRegister } from "./sworker-boot";
import { dbClient } from "./base/load/db/client-db";
const start = async () => {
const base = `${location.protocol}//${location.host}`;
@ -13,12 +14,11 @@ const start = async () => {
root: null as null | ReactRoot,
};
w.mobile = registerMobile();
// sworkerRegister(react);
w.db = dbClient("prasi", location.origin);
sworkerRegister(react);
defineReact();
await defineWindow(false);
// await reloadDBAPI(base, "prod");
// sworkerAddCache(base);
sworkerAddCache(base);
const el = document.getElementById("root");

View File

@ -1,6 +1,6 @@
import init from "wasm-gzip";
import { jscript } from "../../../utils/script/jscript";
import { dbClient } from "../../vi/load/db/client-db";
import { dbClient } from "../../../base/load/db/client-db";
import { PG } from "./ed-global";
import { fetchViaProxy } from "../../vi/load/proxy";

View File

@ -1,8 +1,7 @@
import { createRouter } from "radix3";
import { g } from "../utils/global";
import { serveWS } from "./serve-ws";
import { serveStatic } from "./serve-static";
import { serveAPI } from "./serve-api";
import { serveStatic } from "./serve-static";
import { serveWS } from "./serve-ws";
export const cache = {
static: {} as Record<
@ -20,15 +19,29 @@ export type WSData = { url: URL };
export const createServer = async () => {
await serveAPI.init();
await serveStatic.init();
const { wsHandler } = await import("../../../app/srv/ws/handler");
g.server = Bun.serve({
port: g.port,
maxRequestBodySize: 9999999,
development: true,
websocket: await serveWS(),
websocket: await serveWS(wsHandler),
async fetch(req, server) {
const url = new URL(req.url);
if (wsHandler[url.pathname]) {
if (
server.upgrade(req, {
data: {
url: new URL(req.url),
},
})
) {
return;
}
return new Response("Upgrade failed :(", { status: 500 });
}
if (serveStatic.exists(url)) {
return serveStatic.serve(url);
}

View File

@ -1,9 +1,9 @@
import { WebSocketHandler } from "bun";
import { WSData } from "./create";
export const serveWS: () => Promise<WebSocketHandler<WSData>> = async () => {
const { wsHandler } = await import("../../../app/srv/ws/handler");
export const serveWS: (
wsHandler: Record<string, WebSocketHandler<WSData>>
) => Promise<WebSocketHandler<WSData>> = async (wsHandler) => {
return {
maxPayloadLength: 9999999,
closeOnBackpressureLimit: true,