microframe-ts
Version:
Typescript framework for creating microservices.
39 lines (38 loc) • 1.04 kB
TypeScript
import * as Express from 'express';
/**
* Enum that represents HTTP methods.
*/
export declare enum HttpMethod {
GET = 0,
POST = 1,
PUT = 2,
DELETE = 3
}
/**
* Represents a route in express.
*/
export interface ExpressRoute {
method: HttpMethod;
path: string;
handler: (request: Express.Request, response: Express.Response) => Promise<void>;
}
export interface IController {
router: Express.Router;
routes: string[];
}
/**
* Base controller for REST controllers.
*/
export declare class BaseController implements IController {
router: Express.Router;
routes: string[];
protected path: string;
constructor(path: string);
protected InitRoutes(): void;
/**
* Registers ExpressRoutes with the controller router.
* @remark Also populates the controller routes property; which can be used for debug.
* @param expressRoutes the routes to register with the router.
*/
RegisterRoutes(expressRoutes: ExpressRoute[]): void;
}