mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 01:38:19 +08:00
minor patches & bump deps
This commit is contained in:
19 files changed
+80
-61
No files matched your search
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user