This commit is contained in:
Rizky 2024-02-15 06:30:16 +07:00
parent 02a2e0c121
commit 7e3134d5c0
2 changed files with 36 additions and 22 deletions

View File

@ -69,30 +69,42 @@ export const createServer = async () => {
return api;
}
if (g.deploy.gz && g.deploy.index) {
const core = g.deploy.gz.code.core;
const site = g.deploy.gz.code.site;
let pathname = url.pathname;
if (url.pathname[0] === "/") pathname = pathname.substring(1);
if (
!pathname ||
pathname === "index.html" ||
pathname === "index.htm"
) {
return await serveWeb({
content: g.deploy.index.render(),
pathname: "index.html",
});
if (g.deploy.index) {
if (g.deploy.router) {
const found = g.deploy.router.lookup(url.pathname);
if (found) {
return await serveWeb({
content: g.deploy.index.render(),
pathname: "index.html",
});
}
}
let content = "";
if (core[pathname]) content = core[pathname];
else if (site[pathname]) content = site[pathname];
if (g.deploy.gz) {
const core = g.deploy.gz.code.core;
const site = g.deploy.gz.code.site;
if (content) {
return await serveWeb({ content, pathname });
let pathname = url.pathname;
if (url.pathname[0] === "/") pathname = pathname.substring(1);
if (
!pathname ||
pathname === "index.html" ||
pathname === "index.htm"
) {
return await serveWeb({
content: g.deploy.index.render(),
pathname: "index.html",
});
}
let content = "";
if (core[pathname]) content = core[pathname];
else if (site[pathname]) content = site[pathname];
if (content) {
return await serveWeb({ content, pathname });
}
}
}

View File

@ -86,7 +86,9 @@ export const deploy = {
console.log(
`Downloading site deploy: ${this.config.site_id} [ts: ${this.config.deploy.ts}]`
);
const res = await fetch(`${base_url}/prod-zip/${this.config.site_id}`);
const res = await fetch(
`${base_url}/prod-zip/${this.config.site_id}?ts=${Date.now()}`
);
const ts = Date.now();
const file = Bun.file(dir(`app/web/deploy/${ts}.gz`));