mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: fix 404 page display
This commit is contained in:
11 files changed
+48
-30
No files matched your search
@@ -4,12 +4,12 @@
|
||||
"license": "MIT",
|
||||
"main": "base.mjs",
|
||||
"dependencies": {
|
||||
"@eslint-react/eslint-plugin": "^1.48.5",
|
||||
"@eslint/compat": "^1.2.8",
|
||||
"@eslint-react/eslint-plugin": "^1.49.0",
|
||||
"@eslint/compat": "^1.2.9",
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
"@stylistic/eslint-plugin": "^4.2.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.31.0",
|
||||
"@typescript-eslint/parser": "^8.31.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
||||
"@typescript-eslint/parser": "^8.32.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"eslint-plugin-de-morgan": "^1.2.1",
|
||||
"eslint-plugin-github": "^6.0.0",
|
||||
@@ -18,7 +18,7 @@
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.20",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
"globals": "^16.0.0"
|
||||
"globals": "^16.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": ">= 9"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"sanitize-filename": "^1.6.3",
|
||||
"saslprep": "^1.0.3",
|
||||
"shorty.js": "^1.0.1",
|
||||
"ws": "^8.18.1"
|
||||
"ws": "^8.18.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
|
||||
@@ -343,6 +343,7 @@ export class WebService<C extends CordisContext = CordisContext> extends Service
|
||||
private handlerLayers = [];
|
||||
private wsLayers = [];
|
||||
private captureAllRoutes = Object.create(null);
|
||||
private customDefaultContext: C;
|
||||
|
||||
renderers: Record<string, Renderer> = Object.create(null);
|
||||
server = koa;
|
||||
@@ -449,7 +450,7 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
||||
...this.handlerLayers,
|
||||
{
|
||||
name: '404',
|
||||
func: (t) => this.handleHttp(t, NotFoundHandler, () => true, this.ctx),
|
||||
func: (t) => this.handleHttp(t, NotFoundHandler, () => true, this.customDefaultContext || this.ctx),
|
||||
},
|
||||
]));
|
||||
this.addLayer('base', base(logger, this.config.xff, this.config.xhost));
|
||||
@@ -736,6 +737,21 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
||||
});
|
||||
}
|
||||
|
||||
public setDefaultContext(ctx: C) {
|
||||
try {
|
||||
if (!ctx.server) throw new Error();
|
||||
} catch (e) {
|
||||
throw new Error('Must provide a valid context with server.');
|
||||
}
|
||||
this.ctx.effect(async () => {
|
||||
if (this.customDefaultContext) logger.warn('Default context already set.');
|
||||
this.customDefaultContext = ctx;
|
||||
return () => {
|
||||
this.customDefaultContext = null;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public withHandlerClass<T extends string>(
|
||||
name: T, callback: (HandlerClass: T extends `${string}ConnectionHandler` ? typeof ConnectionHandler<C> : typeof Handler<C>) => any,
|
||||
) {
|
||||
|
||||
+4
-4
@@ -33,7 +33,7 @@
|
||||
"license": "AGPL-3.0-only",
|
||||
"devDependencies": {
|
||||
"@types/autocannon": "^7.12.6",
|
||||
"@types/chai": "^5.2.1",
|
||||
"@types/chai": "^5.2.2",
|
||||
"@types/cross-spawn": "^6.0.6",
|
||||
"@types/node": "22.14.1",
|
||||
"@types/semver": "^7.7.0",
|
||||
@@ -43,17 +43,17 @@
|
||||
"cross-env": "^7.0.3",
|
||||
"cross-spawn": "^7.0.6",
|
||||
"esbuild": "0.25.2",
|
||||
"eslint": "^9.25.1",
|
||||
"eslint": "^9.26.0",
|
||||
"eslint-import-resolver-typescript": "^4.3.4",
|
||||
"eslint-import-resolver-webpack": "^0.13.10",
|
||||
"fs-extra": "^11.3.0",
|
||||
"globals": "^16.0.0",
|
||||
"globals": "^16.1.0",
|
||||
"globby": "~14.0.2",
|
||||
"inspectpack": "^4.7.1",
|
||||
"mongodb-memory-server": "10.1.4",
|
||||
"nyc": "^17.1.0",
|
||||
"ora": "^8.2.0",
|
||||
"oxlint": "^0.16.8",
|
||||
"oxlint": "^0.16.9",
|
||||
"package-json": "^10.0.1",
|
||||
"semver": "^7.7.1",
|
||||
"simple-git": "^3.27.0",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"maxmind": "^4.3.24"
|
||||
"maxmind": "^4.3.25"
|
||||
},
|
||||
"preferUnplugged": true
|
||||
}
|
||||
@@ -14,8 +14,8 @@
|
||||
"schemastery": "^3.16.1",
|
||||
"semver": "^7.7.1",
|
||||
"shell-quote": "^1.8.2",
|
||||
"superagent": "^10.2.0",
|
||||
"ws": "^8.18.1"
|
||||
"superagent": "^10.2.1",
|
||||
"ws": "^8.18.2"
|
||||
},
|
||||
"preferUnplugged": true,
|
||||
"license": "AGPL-3.0-or-later",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"@aws-sdk/lib-storage": "3.726.1",
|
||||
"@aws-sdk/s3-presigned-post": "3.726.1",
|
||||
"@aws-sdk/s3-request-presigner": "3.726.1",
|
||||
"@babel/code-frame": "^7.26.2",
|
||||
"@babel/code-frame": "^7.27.1",
|
||||
"@cordisjs/plugin-timer": "1.1.1",
|
||||
"@hydrooj/common": "workspace:^",
|
||||
"@hydrooj/framework": "workspace:^",
|
||||
@@ -41,7 +41,7 @@
|
||||
"mongodb": "^6.16.0",
|
||||
"mongodb-uri": "^0.9.7",
|
||||
"nanoid": "^5.1.5",
|
||||
"nodemailer": "^6.10.1",
|
||||
"nodemailer": "^7.0.2",
|
||||
"notp": "^2.0.3",
|
||||
"p-queue": "^8.1.0",
|
||||
"sanitize-filename": "^1.6.3",
|
||||
@@ -49,7 +49,7 @@
|
||||
"schemastery": "^3.16.1",
|
||||
"semver": "^7.7.1",
|
||||
"shorty.js": "^1.0.1",
|
||||
"superagent": "^10.2.0",
|
||||
"superagent": "^10.2.1",
|
||||
"tar": "6.2.1",
|
||||
"thirty-two": "^1.0.2",
|
||||
"ua-parser-js": "^2.0.3"
|
||||
|
||||
@@ -91,7 +91,8 @@ export async function apply(ctx: Context) {
|
||||
xhost: system.get('server.xhost'),
|
||||
});
|
||||
if (process.env.HYDRO_CLI) return;
|
||||
ctx.inject(['server', 'oauth'], ({ server, on, oauth }) => {
|
||||
ctx.inject(['server', 'oauth', 'setting'], (childContext) => {
|
||||
const { server, on, oauth } = childContext;
|
||||
server.addHandlerLayer('init', async (c, next) => {
|
||||
const init = Date.now();
|
||||
try {
|
||||
@@ -107,7 +108,8 @@ export async function apply(ctx: Context) {
|
||||
}
|
||||
});
|
||||
|
||||
applyApiHandler(ctx, 'api', '/api/:op');
|
||||
applyApiHandler(childContext, 'api', '/api/:op');
|
||||
server.setDefaultContext(childContext);
|
||||
|
||||
for (const addon of [...Object.values(global.addons)].reverse()) {
|
||||
const dir = resolve(addon, 'public');
|
||||
|
||||
@@ -243,7 +243,7 @@ export default async function (env: { watch?: boolean, production?: boolean, mea
|
||||
name(module) {
|
||||
const packageName = module.context.replace(/\\/g, '/').split('node_modules/').pop().split('/')[0];
|
||||
if (packageName === 'monaco-editor-nls') {
|
||||
return `i.monaco.${module.userRequest.replace(/\\/g, '/').split('/').pop().split('.')[0]}`;
|
||||
return `i.monaco.${(module as any).userRequest.replace(/\\/g, '/').split('/').pop().split('.')[0]}`;
|
||||
}
|
||||
return `n.${packageName.replace('@', '')}`;
|
||||
},
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"devDependencies": {
|
||||
"@blueprintjs/core": "^5.19.0",
|
||||
"@fontsource/dm-mono": "^5.2.5",
|
||||
"@fontsource/fira-code": "^5.2.5",
|
||||
"@fontsource/fira-code": "^5.2.6",
|
||||
"@fontsource/inconsolata": "^5.2.5",
|
||||
"@fontsource/jetbrains-mono": "^5.2.5",
|
||||
"@fontsource/pt-mono": "^5.2.5",
|
||||
@@ -22,7 +22,7 @@
|
||||
"@fontsource/ubuntu-mono": "^5.2.5",
|
||||
"@hydrooj/utils": "workspace:^",
|
||||
"@sentry/browser": "^9.15.0",
|
||||
"@sentry/webpack-plugin": "^3.3.1",
|
||||
"@sentry/webpack-plugin": "^3.4.0",
|
||||
"@simplewebauthn/browser": "13.1.0",
|
||||
"@svgr/webpack": "^8.1.0",
|
||||
"@types/html-to-text": "^9.0.4",
|
||||
@@ -34,8 +34,8 @@
|
||||
"@types/nunjucks": "^3.2.6",
|
||||
"@types/pickadate": "^3.5.35",
|
||||
"@types/qrcode": "^1.5.5",
|
||||
"@types/react": "^19.1.2",
|
||||
"@types/react-dom": "^19.1.2",
|
||||
"@types/react": "^19.1.3",
|
||||
"@types/react-dom": "^19.1.3",
|
||||
"@types/redux-logger": "^3.0.13",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"@types/webpack-env": "^1.18.8",
|
||||
@@ -60,7 +60,7 @@
|
||||
"emojis-list": "2.1.0",
|
||||
"esbuild-loader": "^4.3.0",
|
||||
"flatpickr": "^4.6.13",
|
||||
"idb": "^8.0.2",
|
||||
"idb": "^8.0.3",
|
||||
"jquery": "^3.7.1",
|
||||
"jquery-scroll-lock": "^3.1.3",
|
||||
"jquery.easing": "^1.4.1",
|
||||
@@ -72,7 +72,7 @@
|
||||
"monaco-editor": "0.52.2",
|
||||
"monaco-editor-nls": "^3.1.0",
|
||||
"monaco-editor-webpack-plugin": "^7.1.0",
|
||||
"monaco-themes": "^0.4.4",
|
||||
"monaco-themes": "^0.4.5",
|
||||
"monaco-yaml": "5.1.1",
|
||||
"nanoid": "^5.1.5",
|
||||
"normalize.css": "^8.0.1",
|
||||
@@ -115,7 +115,7 @@
|
||||
"timeago.js": "^4.0.2",
|
||||
"ts-loader": "^9.5.2",
|
||||
"web-streams-polyfill": "^4.1.0",
|
||||
"webpack": "^5.99.7",
|
||||
"webpack": "^5.99.8",
|
||||
"webpack-bundle-analyzer": "^4.10.2",
|
||||
"webpack-dev-server": "^5.2.1",
|
||||
"webpack-manifest-plugin": "^5.0.1",
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
"react-dom": "^18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.1.2",
|
||||
"@types/react-dom": "^19.1.2",
|
||||
"@types/react": "^19.1.3",
|
||||
"@types/react-dom": "^19.1.3",
|
||||
"@vitejs/plugin-react-swc": "^3.9.0",
|
||||
"vite": "^6.3.4"
|
||||
"vite": "^6.3.5"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user