UNPKG

2.37 kBTypeScriptView Raw
1/**
2 * Copyright 2018 Google Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { ExpressHandler, Express, ExpressMetadata } from './express';
17import { LambdaHandler, Lambda, LambdaMetadata } from './lambda';
18import { JsonObject } from '../common';
19export interface Frameworks {
20 /** @public */
21 [name: string]: Framework<Function>;
22}
23/** @public */
24export interface Framework<THandler> {
25 /** @public */
26 handle(base: StandardHandler): THandler;
27 /** @public */
28 check(...args: any[]): boolean;
29}
30/** @public */
31export interface OmniHandler extends StandardHandler, ExpressHandler, LambdaHandler {
32 /** @public */
33 (...args: any[]): any;
34}
35export interface FrameworkMetadata {
36 /** @public */
37 [name: string]: any;
38}
39export interface BuiltinFrameworkMetadata extends FrameworkMetadata {
40 /** @public */
41 express?: ExpressMetadata;
42 /** @public */
43 lambda?: LambdaMetadata;
44}
45export interface BuiltinFrameworks extends Frameworks {
46 /**
47 * Plug and play web framework support for express using body-parser
48 * @public
49 */
50 express: Express;
51 /**
52 * Plug and play web framework support for lambda API gateway
53 * @public
54 */
55 lambda: Lambda;
56}
57/** @hidden */
58export declare const builtin: BuiltinFrameworks;
59/** @public */
60export interface StandardResponse {
61 /** @public */
62 status: number;
63 /** @public */
64 body: JsonObject;
65 /** @public */
66 headers?: Headers;
67}
68/** @public */
69export interface Headers {
70 /** @public */
71 [header: string]: string | string[] | undefined;
72}
73/** @public */
74export interface StandardHandler {
75 /** @public */
76 (
77 /** @public */
78 body: JsonObject,
79 /** @public */
80 headers: Headers,
81 /** @public */
82 metadata?: BuiltinFrameworkMetadata): Promise<StandardResponse>;
83}