@tsed/platform-serverless 8.0.0-alpha.5 → 8.0.0-alpha.6
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/lib/esm/builder/PlatformServerless.js.map +1 -1
- package/lib/esm/builder/PlatformServerlessHandler.js.map +1 -1
- package/lib/esm/domain/ServerlessResponseStream.js.map +1 -1
- package/lib/types/builder/PlatformServerless.d.ts +2 -2
- package/lib/types/builder/PlatformServerlessHandler.d.ts +1 -1
- package/lib/types/domain/ServerlessContext.d.ts +1 -1
- package/lib/types/domain/ServerlessResponseStream.d.ts +1 -1
- package/lib/types/utils/getRequestId.d.ts +1 -1
- package/lib/types/utils/setResponseHeaders.d.ts +1 -1
- package/package.json +13 -14
- package/lib/cjs/builder/PlatformServerless.js +0 -180
- package/lib/cjs/builder/PlatformServerless.js.map +0 -1
- package/lib/cjs/builder/PlatformServerlessHandler.js +0 -113
- package/lib/cjs/builder/PlatformServerlessHandler.js.map +0 -1
- package/lib/cjs/domain/ServerlessContext.js +0 -41
- package/lib/cjs/domain/ServerlessContext.js.map +0 -1
- package/lib/cjs/domain/ServerlessEvent.js +0 -3
- package/lib/cjs/domain/ServerlessEvent.js.map +0 -1
- package/lib/cjs/domain/ServerlessRequest.js +0 -95
- package/lib/cjs/domain/ServerlessRequest.js.map +0 -1
- package/lib/cjs/domain/ServerlessResponse.js +0 -198
- package/lib/cjs/domain/ServerlessResponse.js.map +0 -1
- package/lib/cjs/domain/ServerlessResponseStream.js +0 -76
- package/lib/cjs/domain/ServerlessResponseStream.js.map +0 -1
- package/lib/cjs/exports.js +0 -17
- package/lib/cjs/exports.js.map +0 -1
- package/lib/cjs/index.js +0 -18
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/utils/getRequestId.js +0 -15
- package/lib/cjs/utils/getRequestId.js.map +0 -1
- package/lib/cjs/utils/isInAWS.js +0 -12
- package/lib/cjs/utils/isInAWS.js.map +0 -1
- package/lib/cjs/utils/setResponseHeaders.js +0 -47
- package/lib/cjs/utils/setResponseHeaders.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/types-esm/builder/PlatformServerless.d.ts +0 -37
- package/lib/types-esm/builder/PlatformServerlessHandler.d.ts +0 -14
- package/lib/types-esm/domain/ServerlessContext.d.ts +0 -26
- package/lib/types-esm/domain/ServerlessEvent.d.ts +0 -2
- package/lib/types-esm/domain/ServerlessRequest.d.ts +0 -59
- package/lib/types-esm/domain/ServerlessResponse.d.ts +0 -101
- package/lib/types-esm/domain/ServerlessResponseStream.d.ts +0 -27
- package/lib/types-esm/exports.d.ts +0 -3
- package/lib/types-esm/index.d.ts +0 -14
- package/lib/types-esm/utils/getRequestId.d.ts +0 -3
- package/lib/types-esm/utils/isInAWS.d.ts +0 -1
- package/lib/types-esm/utils/setResponseHeaders.d.ts +0 -6
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerlessResponse = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const core_1 = require("@tsed/core");
|
|
6
|
-
const schema_1 = require("@tsed/schema");
|
|
7
|
-
const encodeurl_1 = tslib_1.__importDefault(require("encodeurl"));
|
|
8
|
-
const mime_1 = tslib_1.__importDefault(require("mime"));
|
|
9
|
-
/**
|
|
10
|
-
* @platform
|
|
11
|
-
*/
|
|
12
|
-
class ServerlessResponse {
|
|
13
|
-
#status;
|
|
14
|
-
#body;
|
|
15
|
-
#headers;
|
|
16
|
-
#locals;
|
|
17
|
-
#isHeadersSent;
|
|
18
|
-
constructor($ctx) {
|
|
19
|
-
this.$ctx = $ctx;
|
|
20
|
-
this.#status = 200;
|
|
21
|
-
this.#body = undefined;
|
|
22
|
-
this.#headers = {};
|
|
23
|
-
this.#locals = {};
|
|
24
|
-
this.#isHeadersSent = false;
|
|
25
|
-
}
|
|
26
|
-
get event() {
|
|
27
|
-
return this.$ctx.event;
|
|
28
|
-
}
|
|
29
|
-
get raw() {
|
|
30
|
-
return this.event;
|
|
31
|
-
}
|
|
32
|
-
get request() {
|
|
33
|
-
return this.$ctx.request;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get the current statusCode
|
|
37
|
-
*/
|
|
38
|
-
get statusCode() {
|
|
39
|
-
return this.#status;
|
|
40
|
-
}
|
|
41
|
-
set statusCode(status) {
|
|
42
|
-
this.#status = status;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* An object that contains response local variables scoped to the request, and therefore available only to the view(s) rendered during that request / response cycle (if any). Otherwise, this property is identical to app.locals.
|
|
46
|
-
*
|
|
47
|
-
* This property is useful for exposing request-level information such as the request path name, authenticated user, user settings, and so on.
|
|
48
|
-
*/
|
|
49
|
-
get locals() {
|
|
50
|
-
return this.#locals;
|
|
51
|
-
}
|
|
52
|
-
get isHeadersSent() {
|
|
53
|
-
return this.#isHeadersSent;
|
|
54
|
-
}
|
|
55
|
-
getStatus() {
|
|
56
|
-
return this.#status;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Sets the HTTP status for the response.
|
|
60
|
-
*
|
|
61
|
-
* @param status
|
|
62
|
-
*/
|
|
63
|
-
status(status) {
|
|
64
|
-
this.#status = status;
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
set(name, value) {
|
|
68
|
-
return this.setHeader(name, value);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Returns the HTTP response header specified by field. The match is case-insensitive.
|
|
72
|
-
*
|
|
73
|
-
* ```typescript
|
|
74
|
-
* response.get('Content-Type') // => "text/plain"
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* @param name
|
|
78
|
-
*/
|
|
79
|
-
get(name) {
|
|
80
|
-
return (0, core_1.getValue)(this.#headers, name.toLowerCase());
|
|
81
|
-
}
|
|
82
|
-
getHeaders() {
|
|
83
|
-
return {
|
|
84
|
-
...this.#headers
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
hasStatus() {
|
|
88
|
-
return this.#status !== 200;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Set header `field` to `val`, or pass
|
|
92
|
-
* an object of header fields.
|
|
93
|
-
*
|
|
94
|
-
* Examples:
|
|
95
|
-
* ```typescript
|
|
96
|
-
* response.setHeaders({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
|
|
97
|
-
* ```
|
|
98
|
-
*
|
|
99
|
-
* Aliased as `res.header()`.
|
|
100
|
-
*/
|
|
101
|
-
setHeaders(headers) {
|
|
102
|
-
// apply headers
|
|
103
|
-
Object.entries(headers).forEach(([key, item]) => {
|
|
104
|
-
this.setHeader(key, item);
|
|
105
|
-
});
|
|
106
|
-
return this;
|
|
107
|
-
}
|
|
108
|
-
setHeader(key, item) {
|
|
109
|
-
if (item !== null && item !== undefined) {
|
|
110
|
-
key = key.toLowerCase();
|
|
111
|
-
if (key === "location") {
|
|
112
|
-
// "back" is an alias for the referrer
|
|
113
|
-
if (item === "back") {
|
|
114
|
-
item = this.request.get("Referrer") || "/";
|
|
115
|
-
}
|
|
116
|
-
item = (0, encodeurl_1.default)(String(item));
|
|
117
|
-
}
|
|
118
|
-
this.#headers = {
|
|
119
|
-
...this.#headers,
|
|
120
|
-
[key.toLowerCase()]: item
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Set `Content-Type` response header with `type` through `mime.lookup()`
|
|
127
|
-
* when it does not contain "/", or set the Content-Type to `type` otherwise.
|
|
128
|
-
*
|
|
129
|
-
* Examples:
|
|
130
|
-
*
|
|
131
|
-
* res.type('.html');
|
|
132
|
-
* res.type('html');
|
|
133
|
-
* res.type('json');
|
|
134
|
-
* res.type('application/json');
|
|
135
|
-
* res.type('png');
|
|
136
|
-
*/
|
|
137
|
-
contentType(contentType) {
|
|
138
|
-
this.setHeader("Content-Type", mime_1.default.getType(contentType));
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
contentLength(length) {
|
|
142
|
-
this.setHeader("Content-Length", length);
|
|
143
|
-
return this;
|
|
144
|
-
}
|
|
145
|
-
getContentLength() {
|
|
146
|
-
if (this.get("Content-Length")) {
|
|
147
|
-
return parseInt(this.get("Content-Length"), 10) || 0;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
getContentType() {
|
|
151
|
-
return String(this.get("Content-Type") || "").split(";")[0];
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an [HTTP status code](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
|
|
155
|
-
* If not specified, status defaults to `302 Found`.
|
|
156
|
-
*
|
|
157
|
-
* @param status
|
|
158
|
-
* @param url
|
|
159
|
-
*/
|
|
160
|
-
redirect(status, url) {
|
|
161
|
-
// Set location header
|
|
162
|
-
const address = this.location(url).get("Location");
|
|
163
|
-
const body = `${(0, schema_1.getStatusMessage)(status)}. Redirecting to ${address}`;
|
|
164
|
-
this.status(status).set("Content-Length", Buffer.byteLength(body)).body(body);
|
|
165
|
-
return this;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Sets the response Location HTTP header to the specified path parameter.
|
|
169
|
-
*
|
|
170
|
-
* @param url
|
|
171
|
-
*/
|
|
172
|
-
location(url) {
|
|
173
|
-
return this.set("Location", url);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Send any data to your consumer.
|
|
177
|
-
*
|
|
178
|
-
* This method accept a ReadableStream, a plain object, boolean, string, number, null and undefined data.
|
|
179
|
-
* It choose the better way to send the data.
|
|
180
|
-
*
|
|
181
|
-
* @param body
|
|
182
|
-
*/
|
|
183
|
-
body(body) {
|
|
184
|
-
this.#body = body;
|
|
185
|
-
return this;
|
|
186
|
-
}
|
|
187
|
-
getBody() {
|
|
188
|
-
return this.#body;
|
|
189
|
-
}
|
|
190
|
-
isDone() {
|
|
191
|
-
return this.#isHeadersSent;
|
|
192
|
-
}
|
|
193
|
-
destroy() {
|
|
194
|
-
this.#isHeadersSent = true;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
exports.ServerlessResponse = ServerlessResponse;
|
|
198
|
-
//# sourceMappingURL=ServerlessResponse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ServerlessResponse.js","sourceRoot":"","sources":["../../../src/domain/ServerlessResponse.ts"],"names":[],"mappings":";;;;AAAA,qCAA8C;AAC9C,yCAA8C;AAE9C,kEAAkC;AAClC,wDAAwB;AAKxB;;GAEG;AACH,MAAa,kBAAkB;IAC7B,OAAO,CAAe;IACtB,KAAK,CAAkB;IACvB,QAAQ,CAAmC;IAC3C,OAAO,CAA2B;IAClC,cAAc,CAAS;IAEvB,YAAsB,IAA8B;QAA9B,SAAI,GAAJ,IAAI,CAA0B;QANpD,YAAO,GAAW,GAAG,CAAC;QACtB,UAAK,GAAQ,SAAS,CAAC;QACvB,aAAQ,GAAgC,EAAE,CAAC;QAC3C,YAAO,GAAwB,EAAE,CAAC;QAClC,mBAAc,GAAG,KAAK,CAAC;IAEgC,CAAC;IAExD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACzB,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,UAAU,CAAC,MAAM;QACnB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IA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BAAgB,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9E,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,GAAW;QAClB,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;IAED;;;;;;;OAOG;IACH,IAAI,CAAC,IAAS;QACZ,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAElB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC7B,CAAC;CACF;AApND,gDAoNC"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerlessResponseStream = void 0;
|
|
4
|
-
const node_stream_1 = require("node:stream");
|
|
5
|
-
const isInAWS_1 = require("../utils/isInAWS");
|
|
6
|
-
class ServerlessResponseStream extends node_stream_1.Stream.Writable {
|
|
7
|
-
#response;
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
this._meta = { statusCode: 200, headers: {} };
|
|
11
|
-
this.#response = [];
|
|
12
|
-
}
|
|
13
|
-
static setMeta(resStream, meta) {
|
|
14
|
-
if ((0, isInAWS_1.isInAWS)()) {
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
return awslambda.HttpResponseStream.from(resStream, meta);
|
|
17
|
-
}
|
|
18
|
-
resStream.setMeta(meta);
|
|
19
|
-
return resStream;
|
|
20
|
-
}
|
|
21
|
-
static streamifyResponse(handler) {
|
|
22
|
-
// Check for global awslambda
|
|
23
|
-
if ((0, isInAWS_1.isInAWS)()) {
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
return awslambda.streamifyResponse(async (event, responseStream, context) => {
|
|
26
|
-
const isFallbackMode = context === undefined;
|
|
27
|
-
if (context === undefined) {
|
|
28
|
-
context = responseStream;
|
|
29
|
-
responseStream = new ServerlessResponseStream();
|
|
30
|
-
console.warn({
|
|
31
|
-
event: "WRONG_AWS_STREAM_CONFIGURATION",
|
|
32
|
-
message: "The lambda didn't receive a ResponseStream from AWS. Ts.ED therefore generated a ServerlessResponseStream as a fallback. This mode is not optimized for use in PRODUCTION. Please check the AWS configuration of your lambda."
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
await handler(event, responseStream, context);
|
|
36
|
-
if (isFallbackMode) {
|
|
37
|
-
return ServerlessResponseStream.buildResponse(responseStream);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
return async (event, response, context) => {
|
|
43
|
-
const args = patchArgs([event, response, context]);
|
|
44
|
-
const responseStream = args[1];
|
|
45
|
-
await handler(...args);
|
|
46
|
-
return ServerlessResponseStream.buildResponse(responseStream);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
static buildResponse(responseStream) {
|
|
51
|
-
return {
|
|
52
|
-
...responseStream._meta,
|
|
53
|
-
body: responseStream.getBufferedData().toString()
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
// streams, `chunk` may be any JavaScript value.
|
|
57
|
-
_write(chunk, encoding, callback) {
|
|
58
|
-
this.#response.push(Buffer.from(chunk, encoding));
|
|
59
|
-
callback();
|
|
60
|
-
}
|
|
61
|
-
setMeta(meta) {
|
|
62
|
-
this._meta = meta;
|
|
63
|
-
}
|
|
64
|
-
getBufferedData() {
|
|
65
|
-
return Buffer.concat(this.#response);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
exports.ServerlessResponseStream = ServerlessResponseStream;
|
|
69
|
-
function patchArgs(args) {
|
|
70
|
-
if (!(args[1] instanceof ServerlessResponseStream)) {
|
|
71
|
-
const responseStream = new ServerlessResponseStream();
|
|
72
|
-
return [args[0], responseStream, ...args.splice(1, -1)];
|
|
73
|
-
}
|
|
74
|
-
return args;
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=ServerlessResponseStream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ServerlessResponseStream.js","sourceRoot":"","sources":["../../../src/domain/ServerlessResponseStream.ts"],"names":[],"mappings":";;;AACA,6CAAmC;AACnC,8CAAyC;AAoBzC,MAAa,wBAAyB,SAAQ,oBAAM,CAAC,QAAQ;IAE3D,SAAS,CAAW;IAEpB;QACE,KAAK,EAAE,CAAC;QAJH,UAAK,GAA2B,EAAC,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAC,CAAC;QAKpE,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,SAAmC,EAAE,IAA4B;QAC9E,IAAI,IAAA,iBAAO,GAAE,EAAE;YACb,aAAa;YACb,OAAO,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;SAC3D;QAED,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAExB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,OAAuB;QAC9C,6BAA6B;QAC7B,IAAI,IAAA,iBAAO,GAAE,EAAE;YACb,aAAa;YACb,OAAO,SAAS,CAAC,iBAAiB,CAChC,KAAK,EAAE,KAA6B,EAAE,cAA8D,EAAE,OAAiB,EAAE,EAAE;gBACzH,MAAM,cAAc,GAAG,OAAO,KAAK,SAAS,CAAC;gBAE7C,IAAI,OAAO,KAAK,SAAS,EAAE;oBACzB,OAAO,GAAG,cAAyB,CAAC;oBACpC,cAAc,GAAG,IAAI,wBAAwB,EAAE,CAAC;oBAEhD,OAAO,CAA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C5B,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,wBAAwB,CAAC,EAAE;QAClD,MAAM,cAAc,GAAG,IAAI,wBAAwB,EAAE,CAAC;QAEtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;KACzD;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/lib/cjs/exports.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Lambda = exports.Operation = exports.Options = exports.Patch = exports.Head = exports.Delete = exports.Put = exports.Post = exports.Get = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
tslib_1.__exportStar(require("@tsed/di"), exports);
|
|
6
|
-
var schema_1 = require("@tsed/schema");
|
|
7
|
-
Object.defineProperty(exports, "Get", { enumerable: true, get: function () { return schema_1.Get; } });
|
|
8
|
-
Object.defineProperty(exports, "Post", { enumerable: true, get: function () { return schema_1.Post; } });
|
|
9
|
-
Object.defineProperty(exports, "Put", { enumerable: true, get: function () { return schema_1.Put; } });
|
|
10
|
-
Object.defineProperty(exports, "Delete", { enumerable: true, get: function () { return schema_1.Delete; } });
|
|
11
|
-
Object.defineProperty(exports, "Head", { enumerable: true, get: function () { return schema_1.Head; } });
|
|
12
|
-
Object.defineProperty(exports, "Patch", { enumerable: true, get: function () { return schema_1.Patch; } });
|
|
13
|
-
Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return schema_1.Options; } });
|
|
14
|
-
Object.defineProperty(exports, "Operation", { enumerable: true, get: function () { return schema_1.Operation; } });
|
|
15
|
-
Object.defineProperty(exports, "Lambda", { enumerable: true, get: function () { return schema_1.Operation; } });
|
|
16
|
-
tslib_1.__exportStar(require("@tsed/platform-params"), exports);
|
|
17
|
-
//# sourceMappingURL=exports.js.map
|
package/lib/cjs/exports.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":";;;;AAAA,mDAAyB;AACzB,uCAA0G;AAAlG,6FAAA,GAAG,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,6FAAA,GAAG,OAAA;AAAE,gGAAA,MAAM,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,+FAAA,KAAK,OAAA;AAAE,iGAAA,OAAO,OAAA;AAAE,mGAAA,SAAS,OAAA;AAAE,gGAAA,SAAS,OAAU;AACpF,gEAAsC"}
|
package/lib/cjs/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
/**
|
|
5
|
-
* @file Automatically generated by @tsed/barrels.
|
|
6
|
-
*/
|
|
7
|
-
tslib_1.__exportStar(require("./builder/PlatformServerless.js"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./builder/PlatformServerlessHandler.js"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./domain/ServerlessContext.js"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./domain/ServerlessEvent.js"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./domain/ServerlessRequest.js"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./domain/ServerlessResponse.js"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./domain/ServerlessResponseStream.js"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./exports.js"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./utils/getRequestId.js"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./utils/isInAWS.js"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./utils/setResponseHeaders.js"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,0EAAgD;AAChD,iFAAuD;AACvD,wEAA8C;AAC9C,sEAA4C;AAC5C,wEAA8C;AAC9C,yEAA+C;AAC/C,+EAAqD;AACrD,uDAA6B;AAC7B,kEAAwC;AACxC,6DAAmC;AACnC,wEAA8C"}
|
package/lib/cjs/package.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRequestId = void 0;
|
|
4
|
-
const uuid_1 = require("uuid");
|
|
5
|
-
function getRequestId(event, context) {
|
|
6
|
-
if ("headers" in event && event.headers["x-request-id"]) {
|
|
7
|
-
return event.headers["x-request-id"];
|
|
8
|
-
}
|
|
9
|
-
if ("requestContext" in event) {
|
|
10
|
-
return event?.requestContext?.requestId;
|
|
11
|
-
}
|
|
12
|
-
return context?.awsRequestId || (0, uuid_1.v4)().replace(/-/gi, "");
|
|
13
|
-
}
|
|
14
|
-
exports.getRequestId = getRequestId;
|
|
15
|
-
//# sourceMappingURL=getRequestId.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getRequestId.js","sourceRoot":"","sources":["../../../src/utils/getRequestId.ts"],"names":[],"mappings":";;;AACA,+BAAwB;AAGxB,SAAgB,YAAY,CAAC,KAAsB,EAAE,OAAgB;IACnE,IAAI,SAAS,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;QACvD,OAAO,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;KACtC;IAED,IAAI,gBAAgB,IAAI,KAAK,EAAE;QAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,CAAC;KACzC;IAED,OAAO,OAAO,EAAE,YAAY,IAAI,IAAA,SAAE,GAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC1D,CAAC;AAVD,oCAUC"}
|
package/lib/cjs/utils/isInAWS.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isInAWS = void 0;
|
|
4
|
-
function isInAWS() {
|
|
5
|
-
return (
|
|
6
|
-
// @ts-ignore
|
|
7
|
-
globalThis.awslambda !== undefined &&
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
awslambda.streamifyResponse !== undefined);
|
|
10
|
-
}
|
|
11
|
-
exports.isInAWS = isInAWS;
|
|
12
|
-
//# sourceMappingURL=isInAWS.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isInAWS.js","sourceRoot":"","sources":["../../../src/utils/isInAWS.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO;IACrB,OAAO;IACL,aAAa;IACb,UAAU,CAAC,SAAS,KAAK,SAAS;QAClC,aAAa;QACb,SAAS,CAAC,iBAAiB,KAAK,SAAS,CAC1C,CAAC;AACJ,CAAC;AAPD,0BAOC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setResponseHeaders = void 0;
|
|
4
|
-
function mergeHeaders(specHeaders, headers) {
|
|
5
|
-
return Object.entries(specHeaders).reduce((headers, [key, item]) => {
|
|
6
|
-
key = key.toLowerCase();
|
|
7
|
-
const value = headers[key] === undefined ? item.example : headers[key];
|
|
8
|
-
if (value !== undefined) {
|
|
9
|
-
return {
|
|
10
|
-
...headers,
|
|
11
|
-
[key]: String(value)
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
return headers;
|
|
15
|
-
}, headers);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @ignore
|
|
19
|
-
*/
|
|
20
|
-
function setResponseHeaders(ctx) {
|
|
21
|
-
const { response, endpoint } = ctx;
|
|
22
|
-
if (ctx.isDone()) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const operation = endpoint.operation;
|
|
26
|
-
if (!operation) {
|
|
27
|
-
ctx.logger.debug({
|
|
28
|
-
event: "MISSING_OPERATION_METADATA",
|
|
29
|
-
message: "No operation found on the endpoint. The response headers are not set.",
|
|
30
|
-
endpoint: endpoint
|
|
31
|
-
});
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (!response.hasStatus()) {
|
|
35
|
-
// apply status only if isn't already modified
|
|
36
|
-
response.status(operation.getStatus());
|
|
37
|
-
}
|
|
38
|
-
const statusCode = response.statusCode;
|
|
39
|
-
const headers = operation.getHeadersOf(response.statusCode);
|
|
40
|
-
const mergedHeaders = mergeHeaders(headers, response.getHeaders());
|
|
41
|
-
response.setHeaders(mergedHeaders);
|
|
42
|
-
if (operation.isRedirection(statusCode)) {
|
|
43
|
-
response.redirect(statusCode, String(mergedHeaders["location"]));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.setResponseHeaders = setResponseHeaders;
|
|
47
|
-
//# sourceMappingURL=setResponseHeaders.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setResponseHeaders.js","sourceRoot":"","sources":["../../../src/utils/setResponseHeaders.ts"],"names":[],"mappings":";;;AAKA,SAAS,YAAY,CAAC,WAA2D,EAAE,OAAoC;IACrH,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;QACjE,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QAExB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CA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
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Type } from "@tsed/core";
|
|
2
|
-
import { InjectorService } from "@tsed/di";
|
|
3
|
-
import type { Handler } from "aws-lambda";
|
|
4
|
-
import type { Instance } from "find-my-way";
|
|
5
|
-
import type { ServerlessEvent } from "../domain/ServerlessEvent";
|
|
6
|
-
import { type RequestHandler } from "../domain/ServerlessResponseStream";
|
|
7
|
-
export interface PlatformServerlessSettings extends Partial<TsED.Configuration> {
|
|
8
|
-
lambda?: Type[];
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* @platform
|
|
12
|
-
*/
|
|
13
|
-
export declare class PlatformServerless {
|
|
14
|
-
readonly name: string;
|
|
15
|
-
private _injector;
|
|
16
|
-
private _router;
|
|
17
|
-
private _promise;
|
|
18
|
-
get injector(): InjectorService;
|
|
19
|
-
get settings(): import("@tsed/di").DIConfiguration;
|
|
20
|
-
get promise(): Promise<any>;
|
|
21
|
-
static bootstrap(settings?: Partial<TsED.Configuration> & {
|
|
22
|
-
lambda?: Type[];
|
|
23
|
-
}): PlatformServerless;
|
|
24
|
-
/**
|
|
25
|
-
* Create a new handler from the given token and propertyKey. No routing is used here.
|
|
26
|
-
*/
|
|
27
|
-
static callback(token: Type<any>, propertyKey: string, settings?: Partial<TsED.Configuration>): Handler<ServerlessEvent> | RequestHandler;
|
|
28
|
-
handler(): Handler;
|
|
29
|
-
callbacks(tokens?: Type | Type[], callbacks?: any): Record<string, Handler>;
|
|
30
|
-
ready(): Promise<void>;
|
|
31
|
-
stop(): Promise<void>;
|
|
32
|
-
init(): Promise<any>;
|
|
33
|
-
protected callback(token: Type<any>, propertyKey: string): Handler<ServerlessEvent> | RequestHandler;
|
|
34
|
-
protected initRouter(): Promise<Instance<any>>;
|
|
35
|
-
protected createInjector(settings: any): this;
|
|
36
|
-
protected loadInjector(): Promise<void>;
|
|
37
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { InjectorService, TokenProvider } from "@tsed/di";
|
|
2
|
-
import type { PlatformExceptions } from "@tsed/platform-exceptions";
|
|
3
|
-
import { PlatformParams } from "@tsed/platform-params";
|
|
4
|
-
import { ServerlessContext } from "../domain/ServerlessContext.js";
|
|
5
|
-
import type { ServerlessEvent } from "../domain/ServerlessEvent";
|
|
6
|
-
export declare class PlatformServerlessHandler {
|
|
7
|
-
protected injector: InjectorService;
|
|
8
|
-
protected params: PlatformParams;
|
|
9
|
-
protected exceptionsManager: Promise<PlatformExceptions>;
|
|
10
|
-
createHandler(token: TokenProvider, propertyKey: string | symbol): ($ctx: ServerlessContext<ServerlessEvent>) => Promise<Promise<unknown>>;
|
|
11
|
-
private flush;
|
|
12
|
-
private makeHttpResponse;
|
|
13
|
-
private processResult;
|
|
14
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { DIContext, DIContextOptions } from "@tsed/di";
|
|
2
|
-
import { JsonEntityStore } from "@tsed/schema";
|
|
3
|
-
import { type APIGatewayProxyEvent, Context } from "aws-lambda";
|
|
4
|
-
import { ServerlessRequest } from "./ServerlessRequest.js";
|
|
5
|
-
import { ServerlessResponse } from "./ServerlessResponse.js";
|
|
6
|
-
import type { ServerlessResponseStream } from "./ServerlessResponseStream";
|
|
7
|
-
export interface ServerlessContextOptions<Event = APIGatewayProxyEvent> extends DIContextOptions {
|
|
8
|
-
event: Event;
|
|
9
|
-
context: Context;
|
|
10
|
-
responseStream?: ServerlessResponseStream;
|
|
11
|
-
endpoint: JsonEntityStore;
|
|
12
|
-
}
|
|
13
|
-
export declare class ServerlessContext<Event extends object = APIGatewayProxyEvent> extends DIContext {
|
|
14
|
-
readonly response: ServerlessResponse<Event>;
|
|
15
|
-
readonly request: ServerlessRequest<Event>;
|
|
16
|
-
readonly context: Context;
|
|
17
|
-
readonly event: Event;
|
|
18
|
-
readonly responseStream: ServerlessResponseStream | undefined;
|
|
19
|
-
readonly endpoint: JsonEntityStore;
|
|
20
|
-
readonly PLATFORM = "SERVERLESS";
|
|
21
|
-
constructor({ event, context, endpoint, responseStream, ...options }: ServerlessContextOptions<Event>);
|
|
22
|
-
isHttpEvent(): boolean;
|
|
23
|
-
isAuthorizerEvent(): boolean;
|
|
24
|
-
destroy(): Promise<void>;
|
|
25
|
-
isDone(): boolean;
|
|
26
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayTokenAuthorizerEvent, CloudWatchLogsEvent, DynamoDBStreamEvent, KinesisStreamEvent, S3Event, ScheduledEvent, SNSEvent, SQSEvent } from "aws-lambda";
|
|
2
|
-
export type ServerlessEvent = APIGatewayProxyEvent | APIGatewayProxyEventV2 | S3Event | SQSEvent | SNSEvent | DynamoDBStreamEvent | KinesisStreamEvent | CloudWatchLogsEvent | ScheduledEvent | APIGatewayTokenAuthorizerEvent;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { APIGatewayProxyEvent } from "aws-lambda";
|
|
2
|
-
import { ServerlessContext } from "./ServerlessContext.js";
|
|
3
|
-
/**
|
|
4
|
-
* @platform
|
|
5
|
-
*/
|
|
6
|
-
export declare class ServerlessRequest<Event extends object = APIGatewayProxyEvent> {
|
|
7
|
-
protected $ctx: ServerlessContext<Event>;
|
|
8
|
-
constructor($ctx: ServerlessContext<Event>);
|
|
9
|
-
/**
|
|
10
|
-
* APIGatewayProxyEvent to no break the current code
|
|
11
|
-
* @note use getEvent() instead to use generic type
|
|
12
|
-
*/
|
|
13
|
-
get event(): APIGatewayProxyEvent;
|
|
14
|
-
get raw(): Event;
|
|
15
|
-
get response(): import("./ServerlessResponse.js").ServerlessResponse<Event>;
|
|
16
|
-
get secure(): boolean;
|
|
17
|
-
get host(): string;
|
|
18
|
-
get protocol(): string;
|
|
19
|
-
/**
|
|
20
|
-
* Get the url of the request.
|
|
21
|
-
*
|
|
22
|
-
* Is equivalent of `express.response.originalUrl || express.response.url`.
|
|
23
|
-
*/
|
|
24
|
-
get url(): string;
|
|
25
|
-
get headers(): import("aws-lambda").APIGatewayProxyEventHeaders;
|
|
26
|
-
get method(): string;
|
|
27
|
-
/**
|
|
28
|
-
* Contains key-value pairs of data submitted in the request body. By default, it is `undefined`, and is populated when you use
|
|
29
|
-
* `body-parsing` middleware such as `express.json()` or `express.urlencoded()`.
|
|
30
|
-
*/
|
|
31
|
-
get body(): any;
|
|
32
|
-
get rawBody(): any;
|
|
33
|
-
/**
|
|
34
|
-
* This property is an object containing properties mapped to the named route `parameters`.
|
|
35
|
-
* For example, if you have the route `/user/:name`, then the `name` property is available as `req.params.name`.
|
|
36
|
-
* This object defaults to `{}`.
|
|
37
|
-
*/
|
|
38
|
-
get params(): {
|
|
39
|
-
[key: string]: any;
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* This property is an object containing a property for each query string parameter in the route.
|
|
43
|
-
* When query parser is set to disabled, it is an empty object `{}`, otherwise it is the result of the configured query parser.
|
|
44
|
-
*/
|
|
45
|
-
get query(): {
|
|
46
|
-
[key: string]: any;
|
|
47
|
-
};
|
|
48
|
-
getEvent<E = Event>(): E;
|
|
49
|
-
/**
|
|
50
|
-
* Returns the HTTP request header specified by field. The match is case-insensitive.
|
|
51
|
-
*
|
|
52
|
-
* ```typescript
|
|
53
|
-
* request.get('Content-Type') // => "text/plain"
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* @param name
|
|
57
|
-
*/
|
|
58
|
-
get(name: string): any;
|
|
59
|
-
}
|