@micro.ts/core
Version:
Microservice framework with Typescript
28 lines (27 loc) • 1.23 kB
TypeScript
import { AbstractBroker, DefinitionHandlerPair } from "../AbstractBroker";
import { RouteMapper } from "../IBroker";
import { Action } from "../../server/types";
export declare type HttpVerbs = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options';
export interface IHttpListnerConfig {
address?: string;
port?: string | number;
}
export declare abstract class HttpBroker<TServer = any, TRequest = any, TContext = any, TConfig extends IHttpListnerConfig = any> extends AbstractBroker<TConfig> {
/**
* Broker specific server
*/
getConnection(): TServer;
protected server: TServer;
protected abstract paramWrapper(paramName: string): string;
protected abstract respond(result: Action, ctx: TContext): any;
protected abstract registerHandler(value: DefinitionHandlerPair[], route: string, method: string): void;
protected abstract requestMapper: (r: TRequest) => Promise<Action>;
/**
* Maps from route definition to broker-specific route
* @param def Route definition
*/
protected routeMapper: RouteMapper;
protected registerSingleRoute(value: DefinitionHandlerPair[], route: string): void;
getFullPath(): string;
protected registerRoutes(): void;
}