wip checkpoint
This commit is contained in:
parent
6ddbd121cb
commit
9e0c895c37
|
|
@ -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(
|
||||
{},
|
||||
{
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue