Compare commits
4 Commits
76d1c6b33d
...
9ea7f880f3
Author | SHA1 | Date | |
---|---|---|---|
|
9ea7f880f3 | ||
|
4db00f3482 | ||
|
dcafbada0d | ||
|
0f233183ac |
2
.gitignore
vendored
2
.gitignore
vendored
@ -12,6 +12,8 @@ db.sqlite3
|
||||
build/**
|
||||
app/**
|
||||
settings.json
|
||||
comic_config.json
|
||||
**/comic_config.json
|
||||
|
||||
.pnpm-store/**
|
||||
.env
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"watch": ["testdata"]
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ko">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Ionian</title>
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' fonts.googleapis.com;
|
||||
font-src 'self' fonts.gstatic.com">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="/dist/bundle.css">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
|
||||
<!--MetaTag-Outlet-->
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="/dist/bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -6,7 +6,7 @@
|
||||
"scripts": {
|
||||
"compile": "swc src --out-dir dist",
|
||||
"dev": "nodemon -r @swc-node/register --enable-source-maps --exec node app.ts",
|
||||
"start": "node build/app.js"
|
||||
"start": "node dist/app.js"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
@ -94,11 +94,15 @@ async function renderZipImage(ctx: Context, path: string, page: number) {
|
||||
},
|
||||
}));
|
||||
nodeReadableStream.on("error", (err) => {
|
||||
console.error(err);
|
||||
releaseZip(path);
|
||||
console.error("readalbe stream error",err);
|
||||
setTimeout(()=>{
|
||||
releaseZip(path)
|
||||
},100);
|
||||
});
|
||||
nodeReadableStream.on("close", () => {
|
||||
setTimeout(()=>{
|
||||
releaseZip(path);
|
||||
},100);
|
||||
});
|
||||
|
||||
ctx.body = nodeReadableStream;
|
||||
|
@ -18,6 +18,7 @@ import type { DocumentAccessor, TagAccessor, UserAccessor } from "./model/mod";
|
||||
import { getTagRounter } from "./route/tags";
|
||||
|
||||
import { config } from "dotenv";
|
||||
import { extname, join } from "node:path";
|
||||
config();
|
||||
|
||||
class ServerApplication {
|
||||
@ -38,7 +39,7 @@ class ServerApplication {
|
||||
|
||||
this.diffManger = new DiffManager(this.documentController);
|
||||
this.app = new Koa();
|
||||
this.index_html = readFileSync("index.html", "utf-8");
|
||||
this.index_html = readFileSync("dist/index.html", "utf-8");
|
||||
}
|
||||
private async setup() {
|
||||
const setting = get_setting();
|
||||
@ -195,26 +196,38 @@ class ServerApplication {
|
||||
}
|
||||
}
|
||||
private serve_static_file(router: Router) {
|
||||
const static_file_server = (path: string, type: string) => {
|
||||
router.get(`/${path}`, async (ctx, next) => {
|
||||
const setting = get_setting();
|
||||
ctx.type = type;
|
||||
ctx.body = createReadStream(path);
|
||||
ctx.set("x-content-type-options", "no-sniff");
|
||||
if (setting.mode === "development") {
|
||||
ctx.set("cache-control", "no-cache");
|
||||
} else {
|
||||
ctx.set("cache-control", "public, max-age=3600");
|
||||
}
|
||||
});
|
||||
};
|
||||
const setting = get_setting();
|
||||
static_file_server("dist/bundle.css", "css");
|
||||
static_file_server("dist/bundle.js", "js");
|
||||
if (setting.mode === "development") {
|
||||
static_file_server("dist/bundle.js.map", "text");
|
||||
static_file_server("dist/bundle.css.map", "text");
|
||||
}
|
||||
router.get("/assets/(.*)", async (ctx, next) => {
|
||||
const setting = get_setting();
|
||||
const ext = extname(ctx.path);
|
||||
ctx.type = ext;
|
||||
ctx.body = createReadStream(join("dist",`.${ctx.path}`));
|
||||
ctx.set("x-content-type-options", "no-sniff");
|
||||
if (setting.mode === "development") {
|
||||
ctx.set("cache-control", "no-cache");
|
||||
} else {
|
||||
ctx.set("cache-control", "public, max-age=3600");
|
||||
}
|
||||
});
|
||||
// const static_file_server = (path: string, type: string) => {
|
||||
// router.get(`/${path}`, async (ctx, next) => {
|
||||
// const setting = get_setting();
|
||||
// ctx.type = type;
|
||||
// ctx.body = createReadStream(path);
|
||||
// ctx.set("x-content-type-options", "no-sniff");
|
||||
// if (setting.mode === "development") {
|
||||
// ctx.set("cache-control", "no-cache");
|
||||
// } else {
|
||||
// ctx.set("cache-control", "public, max-age=3600");
|
||||
// }
|
||||
// });
|
||||
// };
|
||||
// const setting = get_setting();
|
||||
// static_file_server("dist/bundle.css", "css");
|
||||
// static_file_server("dist/bundle.js", "js");
|
||||
// if (setting.mode === "development") {
|
||||
// static_file_server("dist/bundle.js.map", "text");
|
||||
// static_file_server("dist/bundle.css.map", "text");
|
||||
// }
|
||||
}
|
||||
start_server() {
|
||||
const setting = get_setting();
|
||||
|
Loading…
Reference in New Issue
Block a user