minor patches & bump deps

This commit is contained in:
undefined committed 2025-05-28 14:32:30 +08:00
1 parent 80a9c6a399
commit d9b578d56a
19 files changed
+80 -61

No files matched your search

+3 -2
View File
@@ -10,7 +10,7 @@
"@hydrooj/utils": "workspace:^",
"emoji-regex": "^10.4.0",
"fs-extra": "^11.3.0",
"koa": "^2.16.1",
"koa": "^3.0.0",
"koa-body": "^6.0.1",
"koa-compress": "^5.1.1",
"koa-router": "^13.0.1",
@@ -19,6 +19,7 @@
"path-to-regexp": "^8.2.0",
"sanitize-filename": "^1.6.3",
"saslprep": "^1.0.3",
"schemastery": "^3.16.1",
"shorty.js": "^1.0.1",
"ws": "^8.18.2"
},
@@ -27,7 +28,7 @@
"@types/koa": "^2.15.0",
"@types/koa-compress": "^4.0.6",
"@types/koa-router": "^7.4.8",
"@types/lodash": "^4.17.16",
"@types/lodash": "^4.17.17",
"@types/saslprep": "^1.0.3",
"@types/ws": "^8.18.1"
}
+14 -13
View File
@@ -8,6 +8,7 @@ import fs from 'fs-extra';
import Koa from 'koa';
import Body from 'koa-body';
import Compress from 'koa-compress';
import Schema from 'schemastery';
import { Shorty } from 'shorty.js';
import { WebSocket, WebSocketServer } from 'ws';
import {
@@ -324,19 +325,19 @@ function executeMiddlewareStack(context: any, middlewares: { name: string, func:
return dispatch(0);
}
export interface WebServiceConfig {
keys: string[];
proxy: boolean;
cors?: string;
upload?: string;
port: number;
host?: string;
xff?: string;
xhost?: string;
enableSSE?: boolean;
}
export class WebService<C extends CordisContext = CordisContext> extends Service<never, C> {
static Config = Schema.object({
keys: Schema.array(Schema.string()),
proxy: Schema.boolean(),
cors: Schema.string(),
upload: Schema.string(),
port: Schema.number(),
host: Schema.string(),
xff: Schema.string(),
xhost: Schema.string(),
enableSSE: Schema.boolean(),
});
private registry: Record<string, any> = Object.create(null);
private registrationCount = Counter();
private serverLayers = [];
@@ -352,7 +353,7 @@ export class WebService<C extends CordisContext = CordisContext> extends Service
Handler = Handler;
ConnectionHandler = ConnectionHandler;
constructor(ctx: C, public config: WebServiceConfig) {
constructor(ctx: C, public config: ReturnType<typeof WebService.Config>) {
super(ctx, 'server');
ctx.mixin('server', ['Route', 'Connection', 'withHandlerClass']);
this.server.keys = this.config.keys;