1 | import { Constructor, Context, ValueOrPromise } from '@loopback/core';
|
2 | import { ControllerSpec, OperationObject } from '@loopback/openapi-v3';
|
3 | import { OperationArgs, OperationRetval } from '../types';
|
4 | import { BaseRoute } from './base-route';
|
5 | export type ControllerInstance = {
|
6 | [name: string]: any;
|
7 | } & object;
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | export type ControllerFactory<T extends ControllerInstance> = (ctx: Context) => ValueOrPromise<T>;
|
13 |
|
14 |
|
15 |
|
16 | export type ControllerClass<T extends ControllerInstance> = Constructor<T>;
|
17 |
|
18 |
|
19 |
|
20 | export declare class ControllerRoute<T extends object> extends BaseRoute {
|
21 | protected readonly _controllerCtor: ControllerClass<T>;
|
22 | protected readonly _controllerName: string;
|
23 | protected readonly _methodName: string;
|
24 | protected readonly _controllerFactory: ControllerFactory<T>;
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | constructor(verb: string, path: string, spec: OperationObject, controllerCtor: ControllerClass<T>, controllerFactory?: ControllerFactory<T>, methodName?: string);
|
35 | describe(): string;
|
36 | updateBindings(requestContext: Context): void;
|
37 | invokeHandler(requestContext: Context, args: OperationArgs): Promise<OperationRetval>;
|
38 | }
|
39 | /**
|
40 | * Create a controller factory function for a given binding key
|
41 | * @param key - Binding key
|
42 | */
|
43 | export declare function createControllerFactoryForBinding<T extends object>(key: string): ControllerFactory<T>;
|
44 | /**
|
45 | * Create a controller factory function for a given class
|
46 | * @param controllerCtor - Controller class
|
47 | */
|
48 | export declare function createControllerFactoryForClass<T extends object>(controllerCtor: ControllerClass<T>): ControllerFactory<T>;
|
49 | /**
|
50 | * Create a controller factory function for a given instance
|
51 | * @param controllerCtor - Controller instance
|
52 | */
|
53 | export declare function createControllerFactoryForInstance<T extends object>(controllerInst: T): ControllerFactory<T>;
|
54 | /**
|
55 | * Create routes for a controller with the given spec
|
56 | * @param spec - Controller spec
|
57 | * @param controllerCtor - Controller class
|
58 | * @param controllerFactory - Controller factory
|
59 | */
|
60 | export declare function createRoutesForController<T extends object>(spec: ControllerSpec, controllerCtor: ControllerClass<T>, controllerFactory?: ControllerFactory<T>): ControllerRoute<T>[];
|
61 | export declare function joinPath(basePath: string, path: string): string;
|