UNPKG

2.13 kBTypeScriptView Raw
1import { Action } from '../../Action';
2import { ActionMetadata } from '../../metadata/ActionMetadata';
3import { BaseDriver } from '../BaseDriver';
4import { MiddlewareMetadata } from '../../metadata/MiddlewareMetadata';
5import { ParamMetadata } from '../../metadata/ParamMetadata';
6import { UseMetadata } from '../../metadata/UseMetadata';
7/**
8 * Integration with koa framework.
9 */
10export declare class KoaDriver extends BaseDriver {
11 koa?: any;
12 router?: any;
13 constructor(koa?: any, router?: any);
14 /**
15 * Initializes the things driver needs before routes and middleware registration.
16 */
17 initialize(): void;
18 /**
19 * Registers middleware that run before controller actions.
20 */
21 registerMiddleware(middleware: MiddlewareMetadata): void;
22 /**
23 * Registers action in the driver.
24 */
25 registerAction(actionMetadata: ActionMetadata, executeCallback: (options: Action) => any): void;
26 /**
27 * Registers all routes in the framework.
28 */
29 registerRoutes(): void;
30 /**
31 * Gets param from the request.
32 */
33 getParamFromRequest(actionOptions: Action, param: ParamMetadata): any;
34 /**
35 * Handles result of successfully executed controller action.
36 */
37 handleSuccess(result: any, action: ActionMetadata, options: Action): void;
38 /**
39 * Handles result of failed executed controller action.
40 */
41 handleError(error: any, action: ActionMetadata | undefined, options: Action): Promise<unknown>;
42 /**
43 * Creates middlewares from the given "use"-s.
44 */
45 protected prepareMiddlewares(uses: UseMetadata[]): Function[];
46 /**
47 * Dynamically loads koa and required koa-router module.
48 */
49 protected loadKoa(): void;
50 /**
51 * Dynamically loads koa-router module.
52 */
53 private loadRouter;
54 /**
55 * Dynamically loads koa-multer module.
56 */
57 private loadMulter;
58 /**
59 * This middleware fixes a bug on koa-multer implementation.
60 *
61 * This bug should be fixed by koa-multer PR #15: https://github.com/koa-modules/multer/pull/15
62 */
63 private fixMulterRequestAssignment;
64}