actionhero
Version:
actionhero.js is a multi-transport API Server with integrated cluster capabilities and delayed tasks
43 lines (42 loc) • 1.25 kB
TypeScript
import { Initializer, Connection } from "../index";
/**
* ```js
*var connectionMiddleware = {
*name: 'connection middleware',
*priority: 1000,
*create: (connection) => {
* // do stuff
*},
*destroy:(connection) => {
* // do stuff
*}
*}
* ```
*/
export interface ConnectionMiddleware {
/**Unique name for the middleware. */
name: string;
/**Module load order. Defaults to `api.config.general.defaultMiddlewarePriority`. */
priority?: number;
/**Called for each new connection when it is created. Connection is passed to the event handler*/
create?: Function;
/**Called for each connection before it is destroyed. Connection is passed to the event handler*/
destroy?: Function;
}
export interface ConnectionsApi {
connections: {
[key: string]: Connection;
};
middleware: {
[key: string]: ConnectionMiddleware;
};
globalMiddleware: Array<string>;
allowedVerbs: Array<string>;
cleanConnection: Function;
apply: (connectionId: string, method?: string, args?: any) => Promise<Connection>;
addMiddleware: (ConnectionMiddleware: any) => void;
}
export declare class Connections extends Initializer {
constructor();
initialize(config: any): Promise<void>;
}