Compare commits

..

No commits in common. "9ea7f880f3bc2515487128809b35a3adabeb6093" and "76d1c6b33d8d9db9e599dc8d1fab464e2bba540c" have entirely different histories.

6 changed files with 44 additions and 43 deletions

2
.gitignore vendored
View file

@ -12,8 +12,6 @@ db.sqlite3
build/** build/**
app/** app/**
settings.json settings.json
comic_config.json
**/comic_config.json
.pnpm-store/** .pnpm-store/**
.env .env

View file

@ -0,0 +1,3 @@
{
"watch": ["testdata"]
}

View file

@ -0,0 +1,17 @@
<!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>

View file

@ -6,7 +6,7 @@
"scripts": { "scripts": {
"compile": "swc src --out-dir dist", "compile": "swc src --out-dir dist",
"dev": "nodemon -r @swc-node/register --enable-source-maps --exec node app.ts", "dev": "nodemon -r @swc-node/register --enable-source-maps --exec node app.ts",
"start": "node dist/app.js" "start": "node build/app.js"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",

View file

@ -94,15 +94,11 @@ async function renderZipImage(ctx: Context, path: string, page: number) {
}, },
})); }));
nodeReadableStream.on("error", (err) => { nodeReadableStream.on("error", (err) => {
console.error("readalbe stream error",err); console.error(err);
setTimeout(()=>{ releaseZip(path);
releaseZip(path)
},100);
}); });
nodeReadableStream.on("close", () => { nodeReadableStream.on("close", () => {
setTimeout(()=>{
releaseZip(path); releaseZip(path);
},100);
}); });
ctx.body = nodeReadableStream; ctx.body = nodeReadableStream;

View file

@ -18,7 +18,6 @@ import type { DocumentAccessor, TagAccessor, UserAccessor } from "./model/mod";
import { getTagRounter } from "./route/tags"; import { getTagRounter } from "./route/tags";
import { config } from "dotenv"; import { config } from "dotenv";
import { extname, join } from "node:path";
config(); config();
class ServerApplication { class ServerApplication {
@ -39,7 +38,7 @@ class ServerApplication {
this.diffManger = new DiffManager(this.documentController); this.diffManger = new DiffManager(this.documentController);
this.app = new Koa(); this.app = new Koa();
this.index_html = readFileSync("dist/index.html", "utf-8"); this.index_html = readFileSync("index.html", "utf-8");
} }
private async setup() { private async setup() {
const setting = get_setting(); const setting = get_setting();
@ -196,38 +195,26 @@ class ServerApplication {
} }
} }
private serve_static_file(router: Router) { private serve_static_file(router: Router) {
router.get("/assets/(.*)", async (ctx, next) => { const static_file_server = (path: string, type: string) => {
const setting = get_setting(); router.get(`/${path}`, async (ctx, next) => {
const ext = extname(ctx.path); const setting = get_setting();
ctx.type = ext; ctx.type = type;
ctx.body = createReadStream(join("dist",`.${ctx.path}`)); ctx.body = createReadStream(path);
ctx.set("x-content-type-options", "no-sniff"); ctx.set("x-content-type-options", "no-sniff");
if (setting.mode === "development") { if (setting.mode === "development") {
ctx.set("cache-control", "no-cache"); ctx.set("cache-control", "no-cache");
} else { } else {
ctx.set("cache-control", "public, max-age=3600"); 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();
// const setting = get_setting(); static_file_server("dist/bundle.css", "css");
// ctx.type = type; static_file_server("dist/bundle.js", "js");
// ctx.body = createReadStream(path); if (setting.mode === "development") {
// ctx.set("x-content-type-options", "no-sniff"); static_file_server("dist/bundle.js.map", "text");
// if (setting.mode === "development") { static_file_server("dist/bundle.css.map", "text");
// 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() { start_server() {
const setting = get_setting(); const setting = get_setting();