mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
framework: use @cordisjs/core instead
This commit is contained in:
1 parent
221283e8e8
commit
2c8c03153e
10 files changed
+86
-179
No files matched your search
@@ -17,7 +17,7 @@ import type { DocType } from '../model/document';
|
||||
export type Disposable = () => void;
|
||||
export type VoidReturn = Promise<any> | any;
|
||||
type HookType = 'before-prepare' | 'before' | 'before-operation' | 'after' | 'finish';
|
||||
type MapHandlerEvents<N extends string, H extends Handler> = Record<`handler/${HookType}/${N}`, (thisArg: H) => VoidReturn>;
|
||||
type MapHandlerEvents<N extends string, H extends Handler<Context>> = Record<`handler/${HookType}/${N}`, (thisArg: H) => VoidReturn>;
|
||||
type KnownHandlerEvents =
|
||||
MapHandlerEvents<'UserRegister', UserRegisterHandler>
|
||||
& MapHandlerEvents<'ProblemSolution', ProblemSolutionHandler>;
|
||||
@@ -38,7 +38,7 @@ export interface EventMap extends KnownHandlerEvents {
|
||||
'database/config': () => VoidReturn
|
||||
|
||||
'system/setting': (args: Record<string, any>) => VoidReturn
|
||||
'bus/broadcast': (event: keyof EventMap | keyof ServerEvents, payload: any, trace?: string) => VoidReturn
|
||||
'bus/broadcast': (event: keyof EventMap | keyof ServerEvents<Context>, payload: any, trace?: string) => VoidReturn
|
||||
'monitor/update': (type: 'server' | 'judge', $set: any) => VoidReturn
|
||||
'monitor/collect': (info: any) => VoidReturn
|
||||
'api/update': () => void;
|
||||
@@ -93,7 +93,7 @@ export interface EventMap extends KnownHandlerEvents {
|
||||
'contest/balloon': (domainId: string, tid: ObjectId, bdoc: ContestBalloonDoc) => VoidReturn
|
||||
'contest/del': (domainId: string, tid: ObjectId) => VoidReturn
|
||||
|
||||
'oplog/log': (type: string, handler: Handler, args: any, data: any) => VoidReturn;
|
||||
'oplog/log': (type: string, handler: Handler<Context>, args: any, data: any) => VoidReturn;
|
||||
|
||||
'training/list': (query: Filter<TrainingDoc>, handler: any) => VoidReturn
|
||||
'training/get': (tdoc: TrainingDoc, handler: any) => VoidReturn
|
||||
@@ -103,7 +103,7 @@ export interface EventMap extends KnownHandlerEvents {
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/naming-convention */
|
||||
|
||||
declare module 'cordis' {
|
||||
declare module '@cordisjs/core' {
|
||||
interface Events extends EventMap { }
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ const ignoredLimit = `,${argv.options.ignoredLimit},`;
|
||||
const logger = new Logger('server');
|
||||
|
||||
declare module '@hydrooj/framework' {
|
||||
export interface HandlerCommon {
|
||||
export interface HandlerCommon<C> {
|
||||
domain: DomainDoc;
|
||||
|
||||
paginate<T>(cursor: FindCursor<T>, page: number, key: string): Promise<[docs: T[], numPages: number, count: number]>;
|
||||
@@ -73,10 +73,9 @@ export function requireSudo(target: any, funcName: string, obj: any) {
|
||||
|
||||
export interface Handler {
|
||||
domain: DomainDoc;
|
||||
ctx: Context;
|
||||
}
|
||||
export class Handler extends HandlerOriginal {
|
||||
constructor(_, ctx: Context) {
|
||||
export class Handler extends HandlerOriginal<Context> {
|
||||
constructor(_, ctx) {
|
||||
super(_, ctx);
|
||||
this.ctx = ctx.extend({ domain: this.domain });
|
||||
this.renderHTML = ((orig) => function (name: string, args: Record<string, any>) {
|
||||
@@ -114,10 +113,9 @@ export class Handler extends HandlerOriginal {
|
||||
|
||||
export interface ConnectionHandler {
|
||||
domain: DomainDoc;
|
||||
ctx: Context;
|
||||
}
|
||||
export class ConnectionHandler extends ConnectionHandlerOriginal {
|
||||
constructor(_, ctx: Context) {
|
||||
export class ConnectionHandler extends ConnectionHandlerOriginal<Context> {
|
||||
constructor(_, ctx) {
|
||||
super(_, ctx);
|
||||
this.ctx = ctx.extend({ domain: this.domain });
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user