Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb2e261c62 | ||
|
|
4be39ed742 | ||
|
|
8ddb692370 |
No files matched your search
@@ -1,10 +1,10 @@
|
||||
import { constants } from "node:zlib";
|
||||
import Koa from "koa";
|
||||
import Router from "koa-router";
|
||||
import Router from "@koa/router";
|
||||
import * as jwt from "jsonwebtoken";
|
||||
import koaStatic from "koa-static";
|
||||
import koaSend from "koa-send";
|
||||
import koaCompress from "koa-compress";
|
||||
import koaBodyParser from "koa-bodyparser";
|
||||
import koaBodyParser from "@koa/bodyparser";
|
||||
import koaJwt from "koa-jwt";
|
||||
import * as config from "./config.ts";
|
||||
import api from "./ui/api.ts";
|
||||
@@ -18,12 +18,6 @@ import { version as VERSION } from "../package.json";
|
||||
import memoize from "./common/memoize.ts";
|
||||
import { APP_JS, APP_CSS, FAVICON_PNG } from "../build/assets.ts";
|
||||
|
||||
declare module "koa" {
|
||||
interface Request {
|
||||
body: any;
|
||||
}
|
||||
}
|
||||
|
||||
const koa = new Koa();
|
||||
const router = new Router();
|
||||
|
||||
@@ -262,6 +256,17 @@ koa.use(
|
||||
);
|
||||
|
||||
koa.use(router.routes());
|
||||
koa.use(koaStatic(config.ROOT_DIR + "/public"));
|
||||
koa.use(async (ctx, next) => {
|
||||
await next();
|
||||
if (ctx.method !== "HEAD" && ctx.method !== "GET") return;
|
||||
if (ctx.body != null || ctx.status !== 404) return;
|
||||
if (/(?:^|[\\/])\.\.(?:[\\/]|$)/.test(ctx.path)) return;
|
||||
|
||||
try {
|
||||
await koaSend(ctx, ctx.path, { root: config.ROOT_DIR + "/public" });
|
||||
} catch (err) {
|
||||
if (err.status !== 404) throw err;
|
||||
}
|
||||
});
|
||||
|
||||
export const listener = koa.callback();
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { Readable } from "node:stream";
|
||||
import Router from "koa-router";
|
||||
import Router from "@koa/router";
|
||||
import { ObjectId } from "mongodb";
|
||||
import * as db from "./db.ts";
|
||||
import * as apiFunctions from "../api-functions.ts";
|
||||
|
||||
Generated
+433
-462
File diff suppressed because it is too large.
Load diff
+4
-6
@@ -26,17 +26,17 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@breejs/later": "^4.2.0",
|
||||
"@koa/bodyparser": "^5.1.1",
|
||||
"@koa/router": "^13.1.0",
|
||||
"bson": "^4.7.2",
|
||||
"espresso-iisojs": "^1.0.8",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"ipaddr.js": "^2.2.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"koa": "^2.15.3",
|
||||
"koa-bodyparser": "^4.3.0",
|
||||
"koa-compress": "^5.1.0",
|
||||
"koa-jwt": "^4.0.3",
|
||||
"koa-router": "^12.0.0",
|
||||
"koa-static": "^5.0.0",
|
||||
"koa-send": "^5.0.1",
|
||||
"mongodb": "^4.16.0",
|
||||
"parsimmon": "^1.18.1",
|
||||
"seedrandom": "^3.0.5"
|
||||
@@ -46,8 +46,6 @@
|
||||
"@types/jsonwebtoken": "^9.0.6",
|
||||
"@types/koa": "^2.15.0",
|
||||
"@types/koa-compress": "^4.0.6",
|
||||
"@types/koa-router": "^7.4.8",
|
||||
"@types/koa-static": "^4.0.4",
|
||||
"@types/mithril": "^2.2.6",
|
||||
"@types/node": "^20.14.2",
|
||||
"@types/parsimmon": "^1.10.9",
|
||||
@@ -55,7 +53,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
||||
"@typescript-eslint/parser": "^7.12.0",
|
||||
"codemirror": "^5.65.16",
|
||||
"esbuild": "^0.21.4",
|
||||
"esbuild": "^0.25.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"mithril": "^2.2.2",
|
||||
|
||||
Reference in new issue
Block a user