This commit is contained in:
Rizky 2024-03-21 11:37:02 +07:00
parent e66bd5fc1f
commit 80db2618fc
2 changed files with 6 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import { apiContext } from "service-srv";
import { SinglePage, g } from "utils/global"; import { SinglePage, g } from "utils/global";
import { gzipAsync } from "utils/gzip"; import { gzipAsync } from "utils/gzip";
import { getContent } from "../server/prep-api-ts"; import { getContent } from "../server/prep-api-ts";
import mime from "mime";
export const _ = { export const _ = {
url: "/_prasi/**", url: "/_prasi/**",
@ -20,6 +21,8 @@ export const _ = {
if (gz) { if (gz) {
const path = parts.slice(1).join("/"); const path = parts.slice(1).join("/");
if (gz.code.site[path]) { if (gz.code.site[path]) {
const type = mime.getType(path);
if (type) res.setHeader("content-type", type);
res.send( res.send(
gz.code.site[path], gz.code.site[path],
req.headers.get("accept-encoding") || "" req.headers.get("accept-encoding") || ""

View File

@ -64,7 +64,7 @@ export const createServer = async () => {
return arg; return arg;
}; };
}; };
g.server = Bun.serve({ g.server = Bun.serve({
port: g.port, port: g.port,
maxRequestBodySize: 1024 * 1024 * 128, maxRequestBodySize: 1024 * 1024 * 128,
@ -73,6 +73,7 @@ export const createServer = async () => {
const handle = async (req: Request) => { const handle = async (req: Request) => {
const api = await serveAPI(url, req); const api = await serveAPI(url, req);
if (api) { if (api) {
return api; return api;
} }
@ -131,7 +132,7 @@ export const createServer = async () => {
(await existsAsync(dir(`app/web/server/index.js`))) (await existsAsync(dir(`app/web/server/index.js`)))
) { ) {
const res = require(dir(`app/web/server/index.js`)); const res = require(dir(`app/web/server/index.js`));
if (res && typeof res.server === 'object') { if (res && typeof res.server === "object") {
g.deploy.server = res.server; g.deploy.server = res.server;
} }
} }