@xpresser/events-server
Version:
Xpresser's Official Events Server Plugin.
47 lines (46 loc) • 1.23 kB
TypeScript
import type { DollarSign } from "xpresser/types";
import "xpresser/types";
import PlaneSocket from "./PlaneSocket";
export declare type EventRoute = {
url: string;
method: string;
path: string;
controller: any;
};
export declare type EventDetails = {
eventId: string;
event: string;
args: any[];
};
export declare type EventsArray = Array<{
event: string;
handler: any;
controller: string;
}>;
export interface EventsControllerContext {
id: string;
event: string;
$: DollarSign;
runEvent(event: string, ...args: any[]): any;
reply(severSideEvent: string, ...args: any[]): any;
}
export declare type EventHandlerFn = (ctx: EventsControllerContext, ...args: any[]) => any;
export declare type EventsController = Record<string, string | EventHandlerFn>;
export declare type SocketOrIdAndSocket = PlaneSocket | [string, PlaneSocket];
export declare type EventsServerConfig = {
secretKey: string;
port: number;
log: {
args: boolean;
};
dbPaths: {
server: string;
communicator: string;
};
controlPanel: {
enabled: boolean;
password: string;
routePath: string;
};
communicatorName?: string;
};