fix main server.js
This commit is contained in:
parent
b28b0462ff
commit
72e4c71d61
File diff suppressed because one or more lines are too long
|
|
@ -29,7 +29,8 @@ export const initServer = async (
|
|||
}
|
||||
|
||||
code.internal.server[id_site] = {
|
||||
rebuilding: false, ts: 0,
|
||||
rebuilding: false,
|
||||
ts: 0,
|
||||
ctx: await context({
|
||||
absWorkingDir: dir.data(root),
|
||||
entryPoints: ["server.ts"],
|
||||
|
|
@ -102,9 +103,10 @@ export const initServer = async (
|
|||
} else {
|
||||
db = global.db;
|
||||
api = global.api;
|
||||
}`,
|
||||
}
|
||||
`,
|
||||
},
|
||||
})
|
||||
}),
|
||||
};
|
||||
|
||||
code.internal.server[id_site].rebuilding = true;
|
||||
|
|
|
|||
|
|
@ -57,13 +57,14 @@ const serverMain = () => ({
|
|||
this.handler[site_id] = svr.server;
|
||||
svr.server.site_id = site_id;
|
||||
|
||||
if (typeof svr.server.init === "function") {
|
||||
await svr.server.init({});
|
||||
}
|
||||
Bun.write(
|
||||
Bun.file(code.path(site_id, "site", "src", "server.log")),
|
||||
""
|
||||
);
|
||||
|
||||
if (typeof svr.server.init === "function") {
|
||||
await svr.server.init({});
|
||||
}
|
||||
} else {
|
||||
const file = await Bun.file(server_src_path).text();
|
||||
const log_path = code.path(site_id, "site", "src", "server.log");
|
||||
|
|
|
|||
|
|
@ -175,9 +175,14 @@ export const fetchSendDb = async (params: any, dburl: string) => {
|
|||
let result = await cachedQueryResult[hsum].promise;
|
||||
cached = cachedQueryResult[hsum];
|
||||
try {
|
||||
if (typeof result === "string") {
|
||||
result = JSON.parse(result);
|
||||
cachedQueryResult[hsum].result = result;
|
||||
return result;
|
||||
} else {
|
||||
cachedQueryResult[hsum].result = result;
|
||||
return result;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("DBQuery failed:", result);
|
||||
}
|
||||
|
|
@ -188,7 +193,12 @@ export const fetchSendDb = async (params: any, dburl: string) => {
|
|||
let result = await cached.promise;
|
||||
if (result) {
|
||||
try {
|
||||
return JSON.parse(result);
|
||||
if (typeof result === "string") {
|
||||
result = JSON.parse(result);
|
||||
return result;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("DBQuery failed:", result);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue