@ez4/gateway 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/library.cjs +152 -149
- package/dist/library.mjs +158 -151
- package/dist/main.cjs +1 -0
- package/dist/main.mjs +1 -0
- package/dist/metadata/authorizer.d.ts +2 -2
- package/dist/metadata/cors.d.ts +2 -4
- package/dist/metadata/defaults.d.ts +2 -2
- package/dist/metadata/handler.d.ts +2 -2
- package/dist/metadata/request.d.ts +3 -5
- package/dist/metadata/response.d.ts +3 -5
- package/dist/metadata/route.d.ts +2 -2
- package/dist/types/common.d.ts +3 -3
- package/package.json +7 -7
- package/dist/metadata/catcher.d.ts +0 -3
- package/dist/services/cors.d.ts +0 -29
- package/dist/services/helpers.d.ts +0 -7
- package/dist/services/http.d.ts +0 -106
- package/dist/services/request.d.ts +0 -43
- package/dist/services/response.d.ts +0 -27
- package/dist/types/authorizer.d.ts +0 -9
- package/dist/types/cors.d.ts +0 -8
- package/dist/types/handler.d.ts +0 -9
- package/dist/types/path.d.ts +0 -9
- package/dist/types/request.d.ts +0 -13
- package/dist/types/response.d.ts +0 -9
- package/dist/types/route.d.ts +0 -13
package/dist/services/http.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { Service } from '@ez4/common';
|
|
2
|
-
import type { LinkedVariables } from '@ez4/project/library';
|
|
3
|
-
import type { HttpPath } from '../types/path.js';
|
|
4
|
-
import type { HttpAuthResponse, HttpResponse } from './response.js';
|
|
5
|
-
import type { HttpRequest, HttpAuthRequest } from './request.js';
|
|
6
|
-
import type { RouteTypes } from './helpers.js';
|
|
7
|
-
import type { HttpCors } from './cors.js';
|
|
8
|
-
import type { HttpHeaders, HttpIdentity, HttpPathParameters, HttpQueryStrings, HttpJsonBody } from './common.js';
|
|
9
|
-
/**
|
|
10
|
-
* Provide all contracts for a self-managed HTTP service.
|
|
11
|
-
*/
|
|
12
|
-
export declare namespace Http {
|
|
13
|
-
type Headers = HttpHeaders;
|
|
14
|
-
type Identity = HttpIdentity;
|
|
15
|
-
type PathParameters = HttpPathParameters;
|
|
16
|
-
type QueryStrings = HttpQueryStrings;
|
|
17
|
-
type JsonBody = HttpJsonBody;
|
|
18
|
-
type AuthRequest = HttpAuthRequest;
|
|
19
|
-
type Request = HttpRequest;
|
|
20
|
-
type AuthResponse = HttpAuthResponse;
|
|
21
|
-
type Response = HttpResponse;
|
|
22
|
-
type Cors = HttpCors;
|
|
23
|
-
/**
|
|
24
|
-
* Incoming request.
|
|
25
|
-
*/
|
|
26
|
-
type Incoming<T extends Request> = T & {
|
|
27
|
-
/**
|
|
28
|
-
* Request Id.
|
|
29
|
-
*/
|
|
30
|
-
requestId: string;
|
|
31
|
-
/**
|
|
32
|
-
* Request method.
|
|
33
|
-
*/
|
|
34
|
-
method: string;
|
|
35
|
-
/**
|
|
36
|
-
* Request path.
|
|
37
|
-
*/
|
|
38
|
-
path: string;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Incoming request authorizer.
|
|
42
|
-
*/
|
|
43
|
-
type Authorizer<T extends AuthRequest> = (request: T, context: Service.Context<Service<any>>) => Promise<AuthResponse> | AuthResponse;
|
|
44
|
-
/**
|
|
45
|
-
* Incoming request handler.
|
|
46
|
-
*/
|
|
47
|
-
type Handler<T extends Request> = (request: T, context: Service.Context<Service<any>>) => Promise<Response> | Response;
|
|
48
|
-
/**
|
|
49
|
-
* HTTP route.
|
|
50
|
-
*/
|
|
51
|
-
interface Route<T extends Request = Request> {
|
|
52
|
-
/**
|
|
53
|
-
* Route path.
|
|
54
|
-
*/
|
|
55
|
-
path: HttpPath;
|
|
56
|
-
/**
|
|
57
|
-
* Route authorizer.
|
|
58
|
-
*/
|
|
59
|
-
authorizer?: Authorizer<any>;
|
|
60
|
-
/**
|
|
61
|
-
* Route handler.
|
|
62
|
-
*/
|
|
63
|
-
handler: Handler<T> | Handler<Incoming<T>>;
|
|
64
|
-
/**
|
|
65
|
-
* Variables associated to the route.
|
|
66
|
-
*/
|
|
67
|
-
variables?: LinkedVariables;
|
|
68
|
-
/**
|
|
69
|
-
* Max route execution time (in seconds) for the route.
|
|
70
|
-
*/
|
|
71
|
-
timeout?: number;
|
|
72
|
-
/**
|
|
73
|
-
* Amount of memory available for the handler.
|
|
74
|
-
*/
|
|
75
|
-
memory?: number;
|
|
76
|
-
/**
|
|
77
|
-
* Determines whether or not CORS is enabled for the route.
|
|
78
|
-
*/
|
|
79
|
-
cors?: boolean;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* HTTP service.
|
|
83
|
-
*/
|
|
84
|
-
abstract class Service<T extends Request[] = Request[]> implements Service.Provider {
|
|
85
|
-
/**
|
|
86
|
-
* All expected routes.
|
|
87
|
-
*/
|
|
88
|
-
abstract routes: RouteTypes<T>[];
|
|
89
|
-
/**
|
|
90
|
-
* Display name for the service.
|
|
91
|
-
*/
|
|
92
|
-
name?: string;
|
|
93
|
-
/**
|
|
94
|
-
* CORS configuration.
|
|
95
|
-
*/
|
|
96
|
-
cors?: Cors;
|
|
97
|
-
/**
|
|
98
|
-
* Variables associated to all the routes.
|
|
99
|
-
*/
|
|
100
|
-
variables?: LinkedVariables;
|
|
101
|
-
/**
|
|
102
|
-
* Service client.
|
|
103
|
-
*/
|
|
104
|
-
client: never;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { HttpHeaders, HttpIdentity, HttpPathParameters, HttpQueryStrings, HttpJsonBody } from './common.js';
|
|
2
|
-
/**
|
|
3
|
-
* HTTP authorizer request.
|
|
4
|
-
*/
|
|
5
|
-
export interface HttpAuthRequest {
|
|
6
|
-
/**
|
|
7
|
-
* Expected headers.
|
|
8
|
-
*/
|
|
9
|
-
headers?: HttpHeaders;
|
|
10
|
-
/**
|
|
11
|
-
* Expected path parameters.
|
|
12
|
-
*/
|
|
13
|
-
parameters?: HttpPathParameters;
|
|
14
|
-
/**
|
|
15
|
-
* Expected query strings.
|
|
16
|
-
*/
|
|
17
|
-
query?: HttpQueryStrings;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* HTTP request.
|
|
21
|
-
*/
|
|
22
|
-
export interface HttpRequest {
|
|
23
|
-
/**
|
|
24
|
-
* Expected headers.
|
|
25
|
-
*/
|
|
26
|
-
headers?: HttpHeaders;
|
|
27
|
-
/**
|
|
28
|
-
* Expected identity.
|
|
29
|
-
*/
|
|
30
|
-
identity?: HttpIdentity;
|
|
31
|
-
/**
|
|
32
|
-
* Expected path parameters.
|
|
33
|
-
*/
|
|
34
|
-
parameters?: HttpPathParameters;
|
|
35
|
-
/**
|
|
36
|
-
* Expected query strings.
|
|
37
|
-
*/
|
|
38
|
-
query?: HttpQueryStrings;
|
|
39
|
-
/**
|
|
40
|
-
* Expected JSON body payload.
|
|
41
|
-
*/
|
|
42
|
-
body?: HttpJsonBody;
|
|
43
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { HttpHeaders, HttpIdentity, HttpJsonBody } from './common.js';
|
|
2
|
-
/**
|
|
3
|
-
* HTTP authorizer response.
|
|
4
|
-
*/
|
|
5
|
-
export interface HttpAuthResponse {
|
|
6
|
-
/**
|
|
7
|
-
* Authorization identity.
|
|
8
|
-
*/
|
|
9
|
-
identity?: HttpIdentity;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* HTTP response.
|
|
13
|
-
*/
|
|
14
|
-
export interface HttpResponse {
|
|
15
|
-
/**
|
|
16
|
-
* Response status code.
|
|
17
|
-
*/
|
|
18
|
-
status: number;
|
|
19
|
-
/**
|
|
20
|
-
* Response headers.
|
|
21
|
-
*/
|
|
22
|
-
headers?: HttpHeaders;
|
|
23
|
-
/**
|
|
24
|
-
* Response body.
|
|
25
|
-
*/
|
|
26
|
-
body?: HttpJsonBody;
|
|
27
|
-
}
|
package/dist/types/cors.d.ts
DELETED
package/dist/types/handler.d.ts
DELETED
package/dist/types/path.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* All supported HTTP verbs.
|
|
3
|
-
*/
|
|
4
|
-
export type HttpVerb = 'ANY' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
|
|
5
|
-
/**
|
|
6
|
-
* Valid HTTP path.
|
|
7
|
-
*/
|
|
8
|
-
export type HttpPath = `${HttpVerb} /${string}`;
|
|
9
|
-
export declare const isHttpPath: (path: string) => path is HttpPath;
|
package/dist/types/request.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ObjectSchema, UnionSchema } from '@ez4/schema';
|
|
2
|
-
export type HttpAuthRequest = {
|
|
3
|
-
headers?: ObjectSchema | null;
|
|
4
|
-
parameters?: ObjectSchema | null;
|
|
5
|
-
query?: ObjectSchema | null;
|
|
6
|
-
};
|
|
7
|
-
export type HttpRequest = {
|
|
8
|
-
headers?: ObjectSchema | null;
|
|
9
|
-
identity?: ObjectSchema | UnionSchema | null;
|
|
10
|
-
parameters?: ObjectSchema | null;
|
|
11
|
-
query?: ObjectSchema | null;
|
|
12
|
-
body?: ObjectSchema | UnionSchema | null;
|
|
13
|
-
};
|
package/dist/types/response.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { BooleanSchema, NumberSchema, ObjectSchema, StringSchema, UnionSchema } from '@ez4/schema';
|
|
2
|
-
export type HttpAuthResponse = {
|
|
3
|
-
identity?: ObjectSchema | UnionSchema | null;
|
|
4
|
-
};
|
|
5
|
-
export type HttpResponse = {
|
|
6
|
-
status: number;
|
|
7
|
-
headers?: ObjectSchema | null;
|
|
8
|
-
body?: ObjectSchema | UnionSchema | NumberSchema | StringSchema | BooleanSchema | null;
|
|
9
|
-
};
|
package/dist/types/route.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { LinkedVariables } from '@ez4/project/library';
|
|
2
|
-
import type { HttpAuthorizer } from './authorizer.js';
|
|
3
|
-
import type { HttpHandler } from './handler.js';
|
|
4
|
-
import type { HttpPath } from './path.js';
|
|
5
|
-
export type HttpRoute = {
|
|
6
|
-
path: HttpPath;
|
|
7
|
-
handler: HttpHandler;
|
|
8
|
-
authorizer?: HttpAuthorizer;
|
|
9
|
-
variables?: LinkedVariables | null;
|
|
10
|
-
timeout?: number;
|
|
11
|
-
memory?: number;
|
|
12
|
-
cors?: boolean;
|
|
13
|
-
};
|