reiso
Version:
45 lines (44 loc) • 2.78 kB
TypeScript
import * as express from 'express';
import * as ApolloLink from "apollo-link";
export declare const getHooksGraphQL: () => ((req: any, context: any) => void | Promise<void>)[];
export declare function RegisterHookGraphQL(func: (req: any, context: any) => (Promise<void> | void)): void;
export declare const getHooksWSonConnect: () => ((connectionParams: any, webSocket: any, connectionContext: any) => void | Promise<void>)[];
export declare function RegisterHookWSonConnect(func: (connectionParams: any, webSocket: any, connectionContext: any) => (Promise<void> | void)): void;
export declare const getHooksWSonMessage: () => ((message: any, params: any, webSocket: any) => void | Promise<void>)[];
export declare function RegisterHookWSonMessage(func: (message: any, params: any, webSocket: any) => (Promise<void> | void)): void;
export declare const getHooksWSonDisconnect: () => ((webSocket: any) => void | Promise<void>)[];
export declare function RegisterHookWSonDisconnect(func: (webSocket: any) => (Promise<void> | void)): void;
export declare type Hook = {
linksBefore?: ApolloLink.ApolloLink[];
linksAfter?: ApolloLink.ApolloLink[];
linksWrap?: ApolloLink.ApolloLink;
};
export declare type Func = (req: any, res: any, next: any, context: {
language: string;
} & any, store: any) => (Promise<Hook> | Hook);
export declare const getHooksRender: () => Func[];
export declare function RegisterHookRender(func: Func): void;
export declare const getHooksWebHook: () => ((req: express.Request, res: express.Response, next: express.NextFunction, context: any) => void | Promise<void>)[];
export declare function RegisterHookWebHook(func: (req: express.Request, res: express.Response, next: express.NextFunction, context: any) => (Promise<void> | void)): void;
export declare const getHooksAfterServerStart: () => (() => any)[];
export declare function RegisterHookAfterServerStart(func: () => (Promise<any> | any)): void;
export interface WebHookOption {
path: string;
isAuth?: (params: {
[name: string]: string;
}, body: any, context: any) => (Promise<boolean> | boolean);
auth?: (username: string, password: string, params: {
[name: string]: string;
}, body: any, context: object) => (Promise<boolean> | boolean);
}
export declare type WebHookInterface = WebHookOption & {
func: (params: {
[name: string]: string;
}, body: any, context: object) => (Promise<object> | object);
};
export declare let webHooks: WebHookInterface[];
export declare const getWebHooks: () => WebHookInterface[];
export declare function RegisterWebHook(opt: WebHookOption, func: (params: {
[name: string]: string;
}, body: any, context: object) => (Promise<object> | object)): void;
export declare function clearWebHook(): void;