|
1 | 1 | import {ValidatorOptions} from "class-validator"; |
2 | | -import {HttpError} from "../http-error/HttpError"; |
3 | 2 | import {ClassTransformOptions} from "class-transformer"; |
| 3 | + |
| 4 | +import {HttpError} from "../http-error/HttpError"; |
4 | 5 | import {CurrentUserChecker} from "../CurrentUserChecker"; |
5 | 6 | import {AuthorizationChecker} from "../AuthorizationChecker"; |
| 7 | +import {ActionMetadata} from "../metadata/ActionMetadata"; |
| 8 | +import {ParamMetadata} from "../metadata/ParamMetadata"; |
| 9 | +import {MiddlewareMetadata} from "../metadata/MiddlewareMetadata"; |
| 10 | +import {Action} from "../Action"; |
6 | 11 |
|
7 | 12 | /** |
8 | 13 | * Base driver functionality for all other drivers. |
| 14 | + * Abstract layer to organize controllers integration with different http server implementations. |
9 | 15 | */ |
10 | | -export class BaseDriver { |
| 16 | +export abstract class BaseDriver { |
11 | 17 |
|
12 | 18 | // ------------------------------------------------------------------------- |
13 | 19 | // Public Properties |
@@ -77,6 +83,41 @@ export class BaseDriver { |
77 | 83 | */ |
78 | 84 | currentUserChecker?: CurrentUserChecker; |
79 | 85 |
|
| 86 | + /** |
| 87 | + * Initializes the things driver needs before routes and middleware registration. |
| 88 | + */ |
| 89 | + abstract initialize(): void; |
| 90 | + |
| 91 | + /** |
| 92 | + * Registers given middleware. |
| 93 | + */ |
| 94 | + abstract registerMiddleware(middleware: MiddlewareMetadata): void; |
| 95 | + |
| 96 | + /** |
| 97 | + * Registers action in the driver. |
| 98 | + */ |
| 99 | + abstract registerAction(action: ActionMetadata, executeCallback: (options: Action) => any): void; |
| 100 | + |
| 101 | + /** |
| 102 | + * Registers all routes in the framework. |
| 103 | + */ |
| 104 | + abstract registerRoutes(): void; |
| 105 | + |
| 106 | + /** |
| 107 | + * Gets param from the request. |
| 108 | + */ |
| 109 | + abstract getParamFromRequest(actionOptions: Action, param: ParamMetadata): any; |
| 110 | + |
| 111 | + /** |
| 112 | + * Defines an algorithm of how to handle error during executing controller action. |
| 113 | + */ |
| 114 | + abstract handleError(error: any, action: ActionMetadata, options: Action): any; |
| 115 | + |
| 116 | + /** |
| 117 | + * Defines an algorithm of how to handle success result of executing controller action. |
| 118 | + */ |
| 119 | + abstract handleSuccess(result: any, action: ActionMetadata, options: Action): void; |
| 120 | + |
80 | 121 | // ------------------------------------------------------------------------- |
81 | 122 | // Protected Methods |
82 | 123 | // ------------------------------------------------------------------------- |
|
0 commit comments