| 10 | * Creates dino instance |
| 11 | */ |
| 12 | export class Dino implements IDino { |
| 13 | private appContainer: IAppContainer; |
| 14 | private isBinded = false; |
| 15 | |
| 16 | /** |
| 17 | * app - ExpressApp |
| 18 | * , baseUri - application mounted path |
| 19 | */ |
| 20 | constructor(app: any, baseUri: string) { |
| 21 | this.appContainer = AppContainer.create(app); |
| 22 | this.appContainer.baseUri = baseUri; |
| 23 | this.appContainer.routeNotFoundMiddleware = RouteNotFoundMiddleware; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Register API controller |
| 28 | */ |
| 29 | registerController<T>(controller: Function & { prototype: T }): void { |
| 30 | this.appContainer.controllers.push(controller); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Register RequestStart middleware |
| 35 | */ |
| 36 | requestStart<T>(middleware: Function & { prototype: T }): void { |
| 37 | this.appContainer.startMiddleware.push(middleware); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Register RequestEnd middleware |
| 42 | */ |
| 43 | requestEnd<T>(middleware: Function & { prototype: T }): void { |
| 44 | this.appContainer.endMiddleware.push(middleware); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Register ServerError middleware |
| 49 | */ |
| 50 | serverError<T>(middleware: Function & { prototype: T }): void { |
| 51 | this.appContainer.errorMiddleware.push(middleware); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Register ApplicationStart middleware |
| 56 | */ |
| 57 | applicationStart<T>(middleware: Function & { prototype: T }): void { |
| 58 | this.appContainer.appStartMiddleware.push(middleware); |
| 59 | } |
| 60 | |
| 61 | // Unlike others, We support only one application error controller |
| 62 | /** |
| 63 | * Register ApplicationError controller |
| 64 | */ |
| 65 | registerApplicationError<T>(type: Function & { prototype: T }): void { |
| 66 | this.appContainer.errorController = type; |
| 67 | } |
| 68 | |
| 69 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected