wip fix
This commit is contained in:
parent
af4b8110f6
commit
645f6d1739
|
|
@ -58,6 +58,12 @@ export const createServer = async () => {
|
||||||
await scan(dir(`app/srv/api`));
|
await scan(dir(`app/srv/api`));
|
||||||
await scan(dir(`pkgs/api`));
|
await scan(dir(`pkgs/api`));
|
||||||
|
|
||||||
|
g.createServer = (arg) => {
|
||||||
|
return async (site_id: string) => {
|
||||||
|
return arg;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
g.server = Bun.serve({
|
g.server = Bun.serve({
|
||||||
port: g.port,
|
port: g.port,
|
||||||
async fetch(req) {
|
async fetch(req) {
|
||||||
|
|
@ -121,18 +127,26 @@ export const createServer = async () => {
|
||||||
) {
|
) {
|
||||||
const res = require(dir(`app/web/server/index.js`));
|
const res = require(dir(`app/web/server/index.js`));
|
||||||
if (res && res.server) {
|
if (res && res.server) {
|
||||||
g.deploy.server = res.server;
|
if (typeof res.server === "function") {
|
||||||
|
g.deploy.server = await res.server();
|
||||||
|
} else {
|
||||||
|
g.deploy.server = res.server;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (g.deploy.server && g.deploy.index) {
|
if (g.deploy.server && g.deploy.index) {
|
||||||
return await g.deploy.server.http({
|
try {
|
||||||
handle,
|
return await g.deploy.server.http({
|
||||||
mode: "prod",
|
handle,
|
||||||
req,
|
mode: "prod",
|
||||||
server: g.server,
|
req,
|
||||||
url: { pathname: url.pathname, raw: url },
|
server: g.server,
|
||||||
index: g.deploy.index,
|
url: { pathname: url.pathname, raw: url },
|
||||||
});
|
index: g.deploy.index,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export type SinglePage = {
|
||||||
name: true;
|
name: true;
|
||||||
content_tree: any;
|
content_tree: any;
|
||||||
is_default_layout: true;
|
is_default_layout: true;
|
||||||
}
|
};
|
||||||
|
|
||||||
type PrasiServer = {
|
type PrasiServer = {
|
||||||
ws?: WebSocketHandler<{ url: string }>;
|
ws?: WebSocketHandler<{ url: string }>;
|
||||||
|
|
@ -64,6 +64,9 @@ export const g = global as unknown as {
|
||||||
br: Record<string, Uint8Array>;
|
br: Record<string, Uint8Array>;
|
||||||
br_timeout: Set<string>;
|
br_timeout: Set<string>;
|
||||||
};
|
};
|
||||||
|
createServer: (
|
||||||
|
arg: PrasiServer & { api: any; db: any }
|
||||||
|
) => (site_id: string) => Promise<PrasiServer & { api: any; db: any }>;
|
||||||
deploy: {
|
deploy: {
|
||||||
init: boolean;
|
init: boolean;
|
||||||
raw: any;
|
raw: any;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { $ } from "execa";
|
||||||
import { g } from "./global";
|
import { g } from "./global";
|
||||||
|
|
||||||
export const preparePrisma = async () => {
|
export const preparePrisma = async () => {
|
||||||
if (await existsAsync(dir("app/db/.env"))) {
|
if ((await existsAsync(dir("app/db/.env"))) && !g.db) {
|
||||||
if (g.mode !== "dev") {
|
if (g.mode !== "dev") {
|
||||||
await $({ cwd: dir(`app/db`) })`bun prisma db pull`;
|
await $({ cwd: dir(`app/db`) })`bun prisma db pull`;
|
||||||
await $({ cwd: dir(`app/db`) })`bun prisma generate`;
|
await $({ cwd: dir(`app/db`) })`bun prisma generate`;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue