1 |
|
2 | import Cors from "@koa/cors";
|
3 | import { ActionResult, Application, BodyParserOption, Class, Configuration, Facility, Invocation, KoaMiddleware, Middleware, PlumierApplication, PlumierConfiguration, RouteInfo } from "@plumjs/core";
|
4 | import Koa, { Context } from "koa";
|
5 | export declare function extractDecorators(route: RouteInfo): Middleware[];
|
6 | export declare class MiddlewareInvocation implements Invocation {
|
7 | private middleware;
|
8 | context: Context;
|
9 | private next;
|
10 | constructor(middleware: Middleware, context: Context, next: Invocation);
|
11 | proceed(): Promise<ActionResult>;
|
12 | }
|
13 | export declare class ActionInvocation implements Invocation {
|
14 | context: Context;
|
15 | constructor(context: Context);
|
16 | proceed(): Promise<ActionResult>;
|
17 | }
|
18 | export declare function pipe(middleware: Middleware[], context: Context, invocation: Invocation): Invocation;
|
19 | /**
|
20 | * Preset configuration for building web api. This facility contains:
|
21 | *
|
22 | * body parser: koa-bodyparser
|
23 | *
|
24 | * cors: @koa/cors
|
25 | */
|
26 | export declare class WebApiFacility implements Facility {
|
27 | private opt?;
|
28 | constructor(opt?: {
|
29 | controller?: string | Class | Class[] | undefined;
|
30 | bodyParser?: BodyParserOption | undefined;
|
31 | cors?: Cors.Options | undefined;
|
32 | } | undefined);
|
33 | setup(app: Readonly<PlumierApplication>): Promise<void>;
|
34 | }
|
35 | /**
|
36 | * Preset configuration for building restful style api. This facility contains:
|
37 | *
|
38 | * body parser: koa-bodyparser
|
39 | *
|
40 | * cors: @koa/cors
|
41 | *
|
42 | * default response status: { get: 200, post: 201, put: 204, delete: 204 }
|
43 | */
|
44 | export declare class RestfulApiFacility extends WebApiFacility {
|
45 | setup(app: Readonly<PlumierApplication>): Promise<void>;
|
46 | }
|
47 | export declare class Plumier implements PlumierApplication {
|
48 | readonly config: Readonly<PlumierConfiguration>;
|
49 | readonly koa: Koa;
|
50 | constructor();
|
51 | use(option: KoaMiddleware): Application;
|
52 | use(option: Middleware): Application;
|
53 | set(facility: Facility): Application;
|
54 | set(config: Partial<Configuration>): Application;
|
55 | initialize(): Promise<Koa>;
|
56 | }
|