@tsed/platform-serverless 7.0.0-alpha.1 → 7.0.0-beta.10
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/jest.config.js +4 -4
- package/lib/cjs/builder/PlatformServerless.js +160 -0
- package/lib/cjs/builder/PlatformServerless.js.map +1 -0
- package/lib/cjs/builder/PlatformServerlessHandler.js +93 -0
- package/lib/cjs/builder/PlatformServerlessHandler.js.map +1 -0
- package/lib/cjs/domain/ServerlessContext.js +26 -0
- package/lib/cjs/domain/ServerlessContext.js.map +1 -0
- package/lib/cjs/domain/ServerlessRequest.js +80 -0
- package/lib/cjs/domain/ServerlessRequest.js.map +1 -0
- package/lib/cjs/domain/ServerlessResponse.js +193 -0
- package/lib/cjs/domain/ServerlessResponse.js.map +1 -0
- package/lib/cjs/exports.js +16 -0
- package/lib/cjs/exports.js.map +1 -0
- package/lib/cjs/index.js +15 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/utils/getRequestId.js +13 -0
- package/lib/cjs/utils/getRequestId.js.map +1 -0
- package/lib/cjs/utils/setResponseHeaders.js +35 -0
- package/lib/cjs/utils/setResponseHeaders.js.map +1 -0
- package/lib/esm/builder/PlatformServerless.js +133 -0
- package/lib/esm/builder/PlatformServerless.js.map +1 -0
- package/lib/esm/builder/PlatformServerlessHandler.js +90 -0
- package/lib/esm/builder/PlatformServerlessHandler.js.map +1 -0
- package/lib/esm/domain/ServerlessContext.js +22 -0
- package/lib/esm/domain/ServerlessContext.js.map +1 -0
- package/lib/esm/domain/ServerlessRequest.js +76 -0
- package/lib/esm/domain/ServerlessRequest.js.map +1 -0
- package/lib/esm/domain/ServerlessResponse.js +189 -0
- package/lib/esm/domain/ServerlessResponse.js.map +1 -0
- package/lib/esm/exports.js +4 -0
- package/lib/esm/exports.js.map +1 -0
- package/lib/esm/index.js +12 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/utils/getRequestId.js +9 -0
- package/lib/esm/utils/getRequestId.js.map +1 -0
- package/lib/esm/utils/setResponseHeaders.js +31 -0
- package/lib/esm/utils/setResponseHeaders.js.map +1 -0
- package/lib/{builder → types/builder}/PlatformServerless.d.ts +14 -6
- package/lib/{builder → types/builder}/PlatformServerlessHandler.d.ts +2 -2
- package/lib/{domain → types/domain}/ServerlessContext.d.ts +0 -0
- package/lib/{domain → types/domain}/ServerlessRequest.d.ts +0 -0
- package/lib/{domain → types/domain}/ServerlessResponse.d.ts +1 -1
- package/lib/types/exports.d.ts +3 -0
- package/lib/types/index.d.ts +11 -0
- package/lib/types/utils/getRequestId.d.ts +2 -0
- package/lib/{utils → types/utils}/setResponseHeaders.d.ts +0 -0
- package/package.json +33 -17
- package/readme.md +285 -68
- package/tsconfig.compile.esm.json +12 -0
- package/lib/decorators/lambda.d.ts +0 -58
- package/lib/index.d.ts +0 -9
- package/lib/index.js +0 -1020
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -978
- package/lib/index.modern.js.map +0 -1
- package/lib/services/PlatformServerlessTest.d.ts +0 -40
package/lib/index.js
DELETED
|
@@ -1,1020 +0,0 @@
|
|
|
1
|
-
var di = require('@tsed/di');
|
|
2
|
-
var platformParams = require('@tsed/platform-params');
|
|
3
|
-
var tslib = require('tslib');
|
|
4
|
-
var core = require('@tsed/core');
|
|
5
|
-
var jsonMapper = require('@tsed/json-mapper');
|
|
6
|
-
var platformExceptions = require('@tsed/platform-exceptions');
|
|
7
|
-
var logger = require('@tsed/logger');
|
|
8
|
-
var schema = require('@tsed/schema');
|
|
9
|
-
var uuid = require('uuid');
|
|
10
|
-
var encodeUrl = require('encodeurl');
|
|
11
|
-
var mime = require('mime');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
function _interopNamespace(e) {
|
|
16
|
-
if (e && e.__esModule) return e;
|
|
17
|
-
var n = Object.create(null);
|
|
18
|
-
if (e) {
|
|
19
|
-
Object.keys(e).forEach(function (k) {
|
|
20
|
-
if (k !== 'default') {
|
|
21
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () {
|
|
25
|
-
return e[k];
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
n['default'] = e;
|
|
32
|
-
return n;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
var encodeUrl__default = /*#__PURE__*/_interopDefaultLegacy(encodeUrl);
|
|
36
|
-
var mime__namespace = /*#__PURE__*/_interopNamespace(mime);
|
|
37
|
-
|
|
38
|
-
function _extends() {
|
|
39
|
-
_extends = Object.assign || function (target) {
|
|
40
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
41
|
-
var source = arguments[i];
|
|
42
|
-
|
|
43
|
-
for (var key in source) {
|
|
44
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
45
|
-
target[key] = source[key];
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return target;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return _extends.apply(this, arguments);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
57
|
-
if (source == null) return {};
|
|
58
|
-
var target = {};
|
|
59
|
-
var sourceKeys = Object.keys(source);
|
|
60
|
-
var key, i;
|
|
61
|
-
|
|
62
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
63
|
-
key = sourceKeys[i];
|
|
64
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
65
|
-
target[key] = source[key];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return target;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
var id = 0;
|
|
72
|
-
|
|
73
|
-
function _classPrivateFieldLooseKey(name) {
|
|
74
|
-
return "__private_" + id++ + "_" + name;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function _classPrivateFieldLooseBase(receiver, privateKey) {
|
|
78
|
-
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
|
|
79
|
-
throw new TypeError("attempted to use private field on non-instance");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return receiver;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function mergeHeaders(specHeaders, headers) {
|
|
86
|
-
return Object.entries(specHeaders).reduce((headers, [key, item]) => {
|
|
87
|
-
key = key.toLowerCase();
|
|
88
|
-
return _extends({}, headers, {
|
|
89
|
-
[key]: headers[key] === undefined ? String(item.example) : headers[key]
|
|
90
|
-
});
|
|
91
|
-
}, headers);
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* @ignore
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
function setResponseHeaders(ctx) {
|
|
99
|
-
const {
|
|
100
|
-
response,
|
|
101
|
-
endpoint
|
|
102
|
-
} = ctx;
|
|
103
|
-
const operation = endpoint.operation;
|
|
104
|
-
|
|
105
|
-
if (response.isDone()) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!response.hasStatus()) {
|
|
110
|
-
// apply status only if the isn't already modified
|
|
111
|
-
response.status(operation.getStatus());
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const statusCode = response.statusCode;
|
|
115
|
-
const headers = operation.getHeadersOf(response.statusCode);
|
|
116
|
-
const mergedHeaders = mergeHeaders(headers, response.getHeaders());
|
|
117
|
-
response.setHeaders(mergedHeaders);
|
|
118
|
-
|
|
119
|
-
if (operation.isRedirection(statusCode)) {
|
|
120
|
-
response.redirect(statusCode, String(mergedHeaders["location"]));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function shouldBeSent(data) {
|
|
125
|
-
return Buffer.isBuffer(data) || core.isBoolean(data) || core.isNumber(data) || core.isString(data) || data === null;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function shouldBeSerialized(data) {
|
|
129
|
-
return !(core.isStream(data) || shouldBeSent(data) || data === undefined);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
exports.PlatformServerlessHandler = class PlatformServerlessHandler {
|
|
133
|
-
createHandler(token, propertyKey) {
|
|
134
|
-
const promisedHandler = this.params.compileHandler({
|
|
135
|
-
token,
|
|
136
|
-
propertyKey
|
|
137
|
-
});
|
|
138
|
-
return async $ctx => {
|
|
139
|
-
await this.injector.emit("$onRequest", $ctx);
|
|
140
|
-
await this.injector.runInContext($ctx, async () => {
|
|
141
|
-
try {
|
|
142
|
-
const resolver = new core.AnyToPromise();
|
|
143
|
-
const handler = await promisedHandler;
|
|
144
|
-
const result = await resolver.call(() => handler({
|
|
145
|
-
$ctx
|
|
146
|
-
}));
|
|
147
|
-
this.processResult(result, $ctx);
|
|
148
|
-
} catch (er) {
|
|
149
|
-
$ctx.response.status(500).body(er);
|
|
150
|
-
await this.exceptions.catch(er, $ctx);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
await this.injector.emit("$onResponse", $ctx);
|
|
154
|
-
return this.flush($ctx);
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
flush($ctx) {
|
|
159
|
-
setResponseHeaders($ctx);
|
|
160
|
-
let body = $ctx.response.getBody();
|
|
161
|
-
|
|
162
|
-
if (shouldBeSerialized(body)) {
|
|
163
|
-
body = JSON.stringify(body);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const response = {
|
|
167
|
-
statusCode: $ctx.response.getStatus(),
|
|
168
|
-
body: body === undefined ? "" : body,
|
|
169
|
-
headers: _extends({}, $ctx.response.getHeaders(), {
|
|
170
|
-
"x-request-id": $ctx.id
|
|
171
|
-
}),
|
|
172
|
-
isBase64Encoded: false
|
|
173
|
-
};
|
|
174
|
-
$ctx.destroy();
|
|
175
|
-
return response;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
processResult({
|
|
179
|
-
status,
|
|
180
|
-
headers,
|
|
181
|
-
data
|
|
182
|
-
}, $ctx) {
|
|
183
|
-
if (status) {
|
|
184
|
-
$ctx.response.status(status);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (headers) {
|
|
188
|
-
$ctx.response.setHeaders(headers);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (data !== undefined) {
|
|
192
|
-
data = $ctx.response.getStatus() !== 204 ? data : "";
|
|
193
|
-
|
|
194
|
-
if (shouldBeSerialized(data)) {
|
|
195
|
-
data = jsonMapper.serialize(data, _extends({}, $ctx.endpoint.getResponseOptions()));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
$ctx.response.body(data);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
tslib.__decorate([di.Inject(), tslib.__metadata("design:type", di.InjectorService)], exports.PlatformServerlessHandler.prototype, "injector", void 0);
|
|
205
|
-
|
|
206
|
-
tslib.__decorate([di.Inject(), tslib.__metadata("design:type", platformParams.PlatformParams)], exports.PlatformServerlessHandler.prototype, "params", void 0);
|
|
207
|
-
|
|
208
|
-
tslib.__decorate([di.Inject(), tslib.__metadata("design:type", platformExceptions.PlatformExceptions)], exports.PlatformServerlessHandler.prototype, "exceptions", void 0);
|
|
209
|
-
|
|
210
|
-
exports.PlatformServerlessHandler = tslib.__decorate([di.Injectable({
|
|
211
|
-
scope: di.ProviderScope.SINGLETON,
|
|
212
|
-
imports: [platformParams.DeserializerPipe, platformParams.ValidationPipe]
|
|
213
|
-
})], exports.PlatformServerlessHandler);
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* @platform
|
|
217
|
-
*/
|
|
218
|
-
|
|
219
|
-
class ServerlessRequest {
|
|
220
|
-
constructor({
|
|
221
|
-
event
|
|
222
|
-
}) {
|
|
223
|
-
this.raw = event;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
get secure() {
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
get host() {
|
|
231
|
-
return this.get("host");
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
get protocol() {
|
|
235
|
-
return "https";
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Get the url of the request.
|
|
239
|
-
*
|
|
240
|
-
* Is equivalent of `express.response.originalUrl || express.response.url`.
|
|
241
|
-
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
get url() {
|
|
245
|
-
return this.raw.path;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
get headers() {
|
|
249
|
-
return this.raw.headers;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
get method() {
|
|
253
|
-
return this.raw.httpMethod;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* Contains key-value pairs of data submitted in the request body. By default, it is `undefined`, and is populated when you use
|
|
257
|
-
* `body-parsing` middleware such as `express.json()` or `express.urlencoded()`.
|
|
258
|
-
*/
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
get body() {
|
|
262
|
-
try {
|
|
263
|
-
return this.raw.body ? JSON.parse(this.raw.body) : {};
|
|
264
|
-
} catch (er) {
|
|
265
|
-
return {};
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
get rawBody() {
|
|
270
|
-
return this.raw.body;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* This property is an object containing properties mapped to the named route `parameters`.
|
|
274
|
-
* For example, if you have the route `/user/:name`, then the `name` property is available as `req.params.name`.
|
|
275
|
-
* This object defaults to `{}`.
|
|
276
|
-
*/
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
get params() {
|
|
280
|
-
return this.raw.pathParameters || {};
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* This property is an object containing a property for each query string parameter in the route.
|
|
284
|
-
* When query parser is set to disabled, it is an empty object `{}`, otherwise it is the result of the configured query parser.
|
|
285
|
-
*/
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
get query() {
|
|
289
|
-
return this.raw.queryStringParameters || {};
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Returns the HTTP request header specified by field. The match is case-insensitive.
|
|
293
|
-
*
|
|
294
|
-
* ```typescript
|
|
295
|
-
* request.get('Content-Type') // => "text/plain"
|
|
296
|
-
* ```
|
|
297
|
-
*
|
|
298
|
-
* @param name
|
|
299
|
-
*/
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
get(name) {
|
|
303
|
-
return core.getValue(this.raw.headers, name);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
destroy() {}
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* @platform
|
|
312
|
-
*/
|
|
313
|
-
|
|
314
|
-
var _status = /*#__PURE__*/_classPrivateFieldLooseKey("status");
|
|
315
|
-
|
|
316
|
-
var _body = /*#__PURE__*/_classPrivateFieldLooseKey("body");
|
|
317
|
-
|
|
318
|
-
var _headers = /*#__PURE__*/_classPrivateFieldLooseKey("headers");
|
|
319
|
-
|
|
320
|
-
var _locals = /*#__PURE__*/_classPrivateFieldLooseKey("locals");
|
|
321
|
-
|
|
322
|
-
var _isHeadersSent = /*#__PURE__*/_classPrivateFieldLooseKey("isHeadersSent");
|
|
323
|
-
|
|
324
|
-
var _endListeners = /*#__PURE__*/_classPrivateFieldLooseKey("endListeners");
|
|
325
|
-
|
|
326
|
-
class ServerlessResponse {
|
|
327
|
-
constructor({
|
|
328
|
-
event,
|
|
329
|
-
request
|
|
330
|
-
}) {
|
|
331
|
-
Object.defineProperty(this, _status, {
|
|
332
|
-
writable: true,
|
|
333
|
-
value: void 0
|
|
334
|
-
});
|
|
335
|
-
Object.defineProperty(this, _body, {
|
|
336
|
-
writable: true,
|
|
337
|
-
value: void 0
|
|
338
|
-
});
|
|
339
|
-
Object.defineProperty(this, _headers, {
|
|
340
|
-
writable: true,
|
|
341
|
-
value: void 0
|
|
342
|
-
});
|
|
343
|
-
Object.defineProperty(this, _locals, {
|
|
344
|
-
writable: true,
|
|
345
|
-
value: void 0
|
|
346
|
-
});
|
|
347
|
-
Object.defineProperty(this, _isHeadersSent, {
|
|
348
|
-
writable: true,
|
|
349
|
-
value: void 0
|
|
350
|
-
});
|
|
351
|
-
Object.defineProperty(this, _endListeners, {
|
|
352
|
-
writable: true,
|
|
353
|
-
value: void 0
|
|
354
|
-
});
|
|
355
|
-
_classPrivateFieldLooseBase(this, _status)[_status] = 200;
|
|
356
|
-
_classPrivateFieldLooseBase(this, _body)[_body] = undefined;
|
|
357
|
-
_classPrivateFieldLooseBase(this, _headers)[_headers] = {};
|
|
358
|
-
_classPrivateFieldLooseBase(this, _locals)[_locals] = {};
|
|
359
|
-
_classPrivateFieldLooseBase(this, _isHeadersSent)[_isHeadersSent] = false;
|
|
360
|
-
_classPrivateFieldLooseBase(this, _endListeners)[_endListeners] = [];
|
|
361
|
-
this.event = event;
|
|
362
|
-
this.request = request;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Get the current statusCode
|
|
367
|
-
*/
|
|
368
|
-
get statusCode() {
|
|
369
|
-
return _classPrivateFieldLooseBase(this, _status)[_status];
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
set statusCode(status) {
|
|
373
|
-
_classPrivateFieldLooseBase(this, _status)[_status] = status;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* 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.
|
|
377
|
-
*
|
|
378
|
-
* This property is useful for exposing request-level information such as the request path name, authenticated user, user settings, and so on.
|
|
379
|
-
*/
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
get locals() {
|
|
383
|
-
return _classPrivateFieldLooseBase(this, _locals)[_locals];
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
getStatus() {
|
|
387
|
-
return _classPrivateFieldLooseBase(this, _status)[_status];
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Sets the HTTP status for the response.
|
|
391
|
-
*
|
|
392
|
-
* @param status
|
|
393
|
-
*/
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
status(status) {
|
|
397
|
-
_classPrivateFieldLooseBase(this, _status)[_status] = status;
|
|
398
|
-
return this;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
set(name, value) {
|
|
402
|
-
return this.setHeader(name, value);
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Returns the HTTP response header specified by field. The match is case-insensitive.
|
|
406
|
-
*
|
|
407
|
-
* ```typescript
|
|
408
|
-
* response.get('Content-Type') // => "text/plain"
|
|
409
|
-
* ```
|
|
410
|
-
*
|
|
411
|
-
* @param name
|
|
412
|
-
*/
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
get(name) {
|
|
416
|
-
return core.getValue(_classPrivateFieldLooseBase(this, _headers)[_headers], name.toLowerCase());
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
getHeaders() {
|
|
420
|
-
return _extends({}, _classPrivateFieldLooseBase(this, _headers)[_headers]);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
hasStatus() {
|
|
424
|
-
return _classPrivateFieldLooseBase(this, _status)[_status] !== 200;
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Set header `field` to `val`, or pass
|
|
428
|
-
* an object of header fields.
|
|
429
|
-
*
|
|
430
|
-
* Examples:
|
|
431
|
-
* ```typescript
|
|
432
|
-
* response.setHeaders({ Accept: 'text/plain', 'X-API-Key': 'tobi' });
|
|
433
|
-
* ```
|
|
434
|
-
*
|
|
435
|
-
* Aliased as `res.header()`.
|
|
436
|
-
*/
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
setHeaders(headers) {
|
|
440
|
-
// apply headers
|
|
441
|
-
Object.entries(headers).forEach(([key, item]) => {
|
|
442
|
-
this.setHeader(key, item);
|
|
443
|
-
});
|
|
444
|
-
return this;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
setHeader(key, item) {
|
|
448
|
-
if (item !== null && item !== undefined) {
|
|
449
|
-
key = key.toLowerCase();
|
|
450
|
-
|
|
451
|
-
if (key === "location") {
|
|
452
|
-
// "back" is an alias for the referrer
|
|
453
|
-
if (item === "back") {
|
|
454
|
-
item = this.request.get("Referrer") || "/";
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
item = encodeUrl__default['default'](String(item));
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
_classPrivateFieldLooseBase(this, _headers)[_headers] = _extends({}, _classPrivateFieldLooseBase(this, _headers)[_headers], {
|
|
461
|
-
[key.toLowerCase()]: item
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
return this;
|
|
466
|
-
}
|
|
467
|
-
/**
|
|
468
|
-
* Set `Content-Type` response header with `type` through `mime.lookup()`
|
|
469
|
-
* when it does not contain "/", or set the Content-Type to `type` otherwise.
|
|
470
|
-
*
|
|
471
|
-
* Examples:
|
|
472
|
-
*
|
|
473
|
-
* res.type('.html');
|
|
474
|
-
* res.type('html');
|
|
475
|
-
* res.type('json');
|
|
476
|
-
* res.type('application/json');
|
|
477
|
-
* res.type('png');
|
|
478
|
-
*/
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
contentType(contentType) {
|
|
482
|
-
this.setHeader("Content-Type", mime__namespace.getType(contentType));
|
|
483
|
-
return this;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
contentLength(length) {
|
|
487
|
-
this.setHeader("Content-Length", length);
|
|
488
|
-
return this;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
getContentLength() {
|
|
492
|
-
if (this.get("Content-Length")) {
|
|
493
|
-
return parseInt(this.get("Content-Length"), 10) || 0;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
getContentType() {
|
|
498
|
-
return String(this.get("Content-Type") || "").split(";")[0];
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* 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).
|
|
502
|
-
* If not specified, status defaults to `302 Found`.
|
|
503
|
-
*
|
|
504
|
-
* @param status
|
|
505
|
-
* @param url
|
|
506
|
-
*/
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
redirect(status, url) {
|
|
510
|
-
// Set location header
|
|
511
|
-
const address = this.location(url).get("Location");
|
|
512
|
-
const body = `${schema.getStatusMessage(status)}. Redirecting to ${address}`;
|
|
513
|
-
this.status(status).set("Content-Length", Buffer.byteLength(body)).body(body);
|
|
514
|
-
return this;
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Sets the response Location HTTP header to the specified path parameter.
|
|
518
|
-
*
|
|
519
|
-
* @param url
|
|
520
|
-
*/
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
location(url) {
|
|
524
|
-
return this.set("Location", url);
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Send any data to your consumer.
|
|
528
|
-
*
|
|
529
|
-
* This method accept a ReadableStream, a plain object, boolean, string, number, null and undefined data.
|
|
530
|
-
* It choose the better way to send the data.
|
|
531
|
-
*
|
|
532
|
-
* @param body
|
|
533
|
-
*/
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
body(body) {
|
|
537
|
-
_classPrivateFieldLooseBase(this, _body)[_body] = body;
|
|
538
|
-
return this;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
getBody() {
|
|
542
|
-
return _classPrivateFieldLooseBase(this, _body)[_body];
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
isDone() {
|
|
546
|
-
return _classPrivateFieldLooseBase(this, _isHeadersSent)[_isHeadersSent];
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
onEnd(cb) {
|
|
550
|
-
_classPrivateFieldLooseBase(this, _endListeners)[_endListeners].push(cb);
|
|
551
|
-
|
|
552
|
-
return this;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
destroy() {
|
|
556
|
-
_classPrivateFieldLooseBase(this, _endListeners)[_endListeners].forEach(cb => cb());
|
|
557
|
-
|
|
558
|
-
_classPrivateFieldLooseBase(this, _isHeadersSent)[_isHeadersSent] = true;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
isHeadersSent() {
|
|
562
|
-
return _classPrivateFieldLooseBase(this, _isHeadersSent)[_isHeadersSent];
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
const _excluded = ["event", "context", "endpoint"];
|
|
568
|
-
class ServerlessContext extends di.DIContext {
|
|
569
|
-
constructor(_ref) {
|
|
570
|
-
let {
|
|
571
|
-
event,
|
|
572
|
-
context,
|
|
573
|
-
endpoint
|
|
574
|
-
} = _ref,
|
|
575
|
-
options = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
576
|
-
|
|
577
|
-
super(_extends({}, options, {
|
|
578
|
-
maxStackSize: 0
|
|
579
|
-
}));
|
|
580
|
-
this.context = context;
|
|
581
|
-
this.event = event;
|
|
582
|
-
this.request = new ServerlessRequest({
|
|
583
|
-
event,
|
|
584
|
-
context
|
|
585
|
-
});
|
|
586
|
-
this.response = new ServerlessResponse({
|
|
587
|
-
event,
|
|
588
|
-
context,
|
|
589
|
-
request: this.request
|
|
590
|
-
});
|
|
591
|
-
this.endpoint = endpoint;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
async destroy() {
|
|
595
|
-
await super.destroy();
|
|
596
|
-
this.request.destroy();
|
|
597
|
-
this.response.destroy();
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* @platform
|
|
604
|
-
*/
|
|
605
|
-
|
|
606
|
-
var _injector = /*#__PURE__*/_classPrivateFieldLooseKey("injector");
|
|
607
|
-
|
|
608
|
-
var _promise = /*#__PURE__*/_classPrivateFieldLooseKey("promise");
|
|
609
|
-
|
|
610
|
-
class PlatformServerless {
|
|
611
|
-
constructor() {
|
|
612
|
-
Object.defineProperty(this, _injector, {
|
|
613
|
-
writable: true,
|
|
614
|
-
value: void 0
|
|
615
|
-
});
|
|
616
|
-
Object.defineProperty(this, _promise, {
|
|
617
|
-
writable: true,
|
|
618
|
-
value: void 0
|
|
619
|
-
});
|
|
620
|
-
this.name = "PlatformServerless";
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
get injector() {
|
|
624
|
-
return _classPrivateFieldLooseBase(this, _injector)[_injector];
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
get settings() {
|
|
628
|
-
return this.injector.settings;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
get promise() {
|
|
632
|
-
return _classPrivateFieldLooseBase(this, _promise)[_promise];
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
static bootstrap(settings = {}) {
|
|
636
|
-
const platform = new PlatformServerless();
|
|
637
|
-
platform.bootstrap(settings);
|
|
638
|
-
return platform;
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
callbacks(tokens = [], exports = {}) {
|
|
642
|
-
return this.settings.get("lambda", []).concat(tokens).map(token => {
|
|
643
|
-
const store = schema.JsonEntityStore.from(token);
|
|
644
|
-
return [...store.children.values()].reduce((list, store) => {
|
|
645
|
-
var _store$operation;
|
|
646
|
-
|
|
647
|
-
const operationId = (_store$operation = store.operation) == null ? void 0 : _store$operation.get("operationId");
|
|
648
|
-
return operationId ? [...list, {
|
|
649
|
-
store,
|
|
650
|
-
operationId
|
|
651
|
-
}] : list;
|
|
652
|
-
}, []);
|
|
653
|
-
}).flat().reduce((exports, {
|
|
654
|
-
store,
|
|
655
|
-
operationId
|
|
656
|
-
}) => {
|
|
657
|
-
return _extends({}, exports, {
|
|
658
|
-
[operationId]: this.callback(store.token, store.propertyName)
|
|
659
|
-
});
|
|
660
|
-
}, exports);
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
callback(token, propertyKey) {
|
|
664
|
-
const entity = schema.JsonEntityStore.fromMethod(token, propertyKey);
|
|
665
|
-
let handler;
|
|
666
|
-
return async (event, context) => {
|
|
667
|
-
var _event$requestContext;
|
|
668
|
-
|
|
669
|
-
await _classPrivateFieldLooseBase(this, _promise)[_promise];
|
|
670
|
-
|
|
671
|
-
if (!handler) {
|
|
672
|
-
const platformHandler = _classPrivateFieldLooseBase(this, _injector)[_injector].get(exports.PlatformServerlessHandler);
|
|
673
|
-
|
|
674
|
-
handler = await platformHandler.createHandler(token, propertyKey);
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
const reqId = (event == null ? void 0 : (_event$requestContext = event.requestContext) == null ? void 0 : _event$requestContext.requestId) || uuid.v4().replace(/-/gi, "");
|
|
678
|
-
const $ctx = new ServerlessContext({
|
|
679
|
-
event,
|
|
680
|
-
context,
|
|
681
|
-
id: reqId,
|
|
682
|
-
logger: this.injector.logger,
|
|
683
|
-
injector: this.injector,
|
|
684
|
-
endpoint: entity
|
|
685
|
-
});
|
|
686
|
-
return handler($ctx);
|
|
687
|
-
};
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
async ready() {
|
|
691
|
-
await _classPrivateFieldLooseBase(this, _injector)[_injector].emit("$onReady");
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
async stop() {
|
|
695
|
-
await _classPrivateFieldLooseBase(this, _injector)[_injector].emit("$onDestroy");
|
|
696
|
-
return this.injector.destroy();
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
bootstrap(settings = {}) {
|
|
700
|
-
_classPrivateFieldLooseBase(this, _promise)[_promise] = this.createInjector(_extends({}, settings, {
|
|
701
|
-
PLATFORM_NAME: this.name
|
|
702
|
-
})).loadInjector().then(() => this.ready());
|
|
703
|
-
return this;
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
createInjector(settings) {
|
|
707
|
-
var _settings$logger;
|
|
708
|
-
|
|
709
|
-
_classPrivateFieldLooseBase(this, _injector)[_injector] = new di.InjectorService();
|
|
710
|
-
_classPrivateFieldLooseBase(this, _injector)[_injector].logger = logger.$log;
|
|
711
|
-
|
|
712
|
-
_classPrivateFieldLooseBase(this, _injector)[_injector].settings.set(settings);
|
|
713
|
-
|
|
714
|
-
if (_classPrivateFieldLooseBase(this, _injector)[_injector].settings.get("env") === core.Env.TEST && !(settings != null && (_settings$logger = settings.logger) != null && _settings$logger.level)) {
|
|
715
|
-
logger.$log.stop();
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
return this;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
async loadInjector() {
|
|
722
|
-
const container = di.createContainer();
|
|
723
|
-
di.setLoggerLevel(_classPrivateFieldLooseBase(this, _injector)[_injector]);
|
|
724
|
-
await _classPrivateFieldLooseBase(this, _injector)[_injector].emit("$beforeInit");
|
|
725
|
-
await _classPrivateFieldLooseBase(this, _injector)[_injector].load(container);
|
|
726
|
-
await _classPrivateFieldLooseBase(this, _injector)[_injector].emit("$afterInit");
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
class LambdaClientRequest extends Promise {
|
|
732
|
-
constructor() {
|
|
733
|
-
super(...arguments);
|
|
734
|
-
this.event = LambdaClientRequest.createFakeEvent();
|
|
735
|
-
this.context = LambdaClientRequest.createFakeContext();
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
static call(lambdaName) {
|
|
739
|
-
const resolvers = {};
|
|
740
|
-
const promise = new LambdaClientRequest((resolve, reject) => {
|
|
741
|
-
resolvers.resolve = resolve;
|
|
742
|
-
resolvers.reject = reject;
|
|
743
|
-
});
|
|
744
|
-
promise.init(lambdaName, resolvers.resolve, resolvers.reject);
|
|
745
|
-
return promise;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
static createFakeEvent(event = {}) {
|
|
749
|
-
return _extends({
|
|
750
|
-
body: "",
|
|
751
|
-
headers: {},
|
|
752
|
-
httpMethod: "",
|
|
753
|
-
isBase64Encoded: false,
|
|
754
|
-
multiValueHeaders: {},
|
|
755
|
-
multiValueQueryStringParameters: {},
|
|
756
|
-
path: event.path || "/",
|
|
757
|
-
pathParameters: {},
|
|
758
|
-
queryStringParameters: {},
|
|
759
|
-
resource: "",
|
|
760
|
-
stageVariables: {}
|
|
761
|
-
}, event, {
|
|
762
|
-
requestContext: _extends({}, event == null ? void 0 : event.requestContext, {
|
|
763
|
-
accountId: "",
|
|
764
|
-
apiId: "",
|
|
765
|
-
protocol: "https",
|
|
766
|
-
httpMethod: "",
|
|
767
|
-
identity: {},
|
|
768
|
-
path: event.path || "/",
|
|
769
|
-
stage: "",
|
|
770
|
-
requestId: "requestId",
|
|
771
|
-
requestTimeEpoch: 0,
|
|
772
|
-
resourceId: 1,
|
|
773
|
-
resourcePath: event.path || "/"
|
|
774
|
-
})
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
static createFakeContext(context) {
|
|
779
|
-
return _extends({
|
|
780
|
-
awsRequestId: "awsRequestId",
|
|
781
|
-
callbackWaitsForEmptyEventLoop: false,
|
|
782
|
-
functionName: "",
|
|
783
|
-
functionVersion: "",
|
|
784
|
-
invokedFunctionArn: "",
|
|
785
|
-
logGroupName: "",
|
|
786
|
-
logStreamName: "",
|
|
787
|
-
memoryLimitInMB: ""
|
|
788
|
-
}, context || {});
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
get(path, options = {}) {
|
|
792
|
-
Object.assign(this.event, options);
|
|
793
|
-
this.event.path = path;
|
|
794
|
-
this.event.httpMethod = "GET";
|
|
795
|
-
return this;
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
post(path, body = {}, options = {}) {
|
|
799
|
-
Object.assign(this.event, options);
|
|
800
|
-
this.event.path = path;
|
|
801
|
-
this.event.httpMethod = "POST";
|
|
802
|
-
this.body(body);
|
|
803
|
-
return this;
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
patch(path, body = {}, options = {}) {
|
|
807
|
-
Object.assign(this.event, options);
|
|
808
|
-
this.event.path = path;
|
|
809
|
-
this.event.httpMethod = "PATCH";
|
|
810
|
-
this.body(body);
|
|
811
|
-
return this;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
put(path, body = {}, options = {}) {
|
|
815
|
-
Object.assign(this.event, options);
|
|
816
|
-
this.event.path = path;
|
|
817
|
-
this.event.httpMethod = "PUT";
|
|
818
|
-
this.body(body);
|
|
819
|
-
return this;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
delete(path, body = {}, options = {}) {
|
|
823
|
-
Object.assign(this.event, options);
|
|
824
|
-
this.event.path = path;
|
|
825
|
-
this.event.httpMethod = "POST";
|
|
826
|
-
this.body(body);
|
|
827
|
-
return this;
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
query(query) {
|
|
831
|
-
this.event.queryStringParameters = _extends({}, this.event.queryStringParameters, JSON.parse(JSON.stringify(query)));
|
|
832
|
-
return this;
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
params(pathParameters) {
|
|
836
|
-
this.event.pathParameters = _extends({}, this.event.pathParameters, JSON.parse(JSON.stringify(pathParameters)));
|
|
837
|
-
return this;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
body(body) {
|
|
841
|
-
if (body !== undefined) {
|
|
842
|
-
this.event.headers["content-type"] = "application/json";
|
|
843
|
-
this.event.body = JSON.stringify(body);
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
return this;
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
init(lambda, resolve, reject) {
|
|
850
|
-
setTimeout(async () => {
|
|
851
|
-
try {
|
|
852
|
-
const result = await PlatformServerlessTest.callbacks[lambda](this.event, this.context, resolve);
|
|
853
|
-
resolve(result);
|
|
854
|
-
} catch (er) {
|
|
855
|
-
reject(er);
|
|
856
|
-
}
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
}
|
|
861
|
-
class PlatformServerlessTest extends di.DITest {
|
|
862
|
-
static bootstrap(settings = {}) {
|
|
863
|
-
return async function before() {
|
|
864
|
-
// @ts-ignore
|
|
865
|
-
const instance = await PlatformServerless.bootstrap(di.DITest.configure(settings));
|
|
866
|
-
PlatformServerlessTest.instance = instance;
|
|
867
|
-
PlatformServerlessTest.callbacks = instance.callbacks(); // used by inject method
|
|
868
|
-
|
|
869
|
-
di.DITest.injector = instance.injector;
|
|
870
|
-
return instance.promise;
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* Resets the test injector of the test context, so it won't pollute your next test. Call this in your `tearDown` logic.
|
|
875
|
-
*/
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
static async reset() {
|
|
879
|
-
if (PlatformServerlessTest.instance) {
|
|
880
|
-
await PlatformServerlessTest.instance.stop();
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
if (di.DITest.hasInjector()) {
|
|
884
|
-
await di.DITest.injector.destroy();
|
|
885
|
-
di.DITest._injector = null;
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
static createServerlessContext({
|
|
890
|
-
endpoint
|
|
891
|
-
}) {
|
|
892
|
-
const context = LambdaClientRequest.createFakeContext();
|
|
893
|
-
const event = LambdaClientRequest.createFakeEvent();
|
|
894
|
-
return new ServerlessContext({
|
|
895
|
-
event,
|
|
896
|
-
context,
|
|
897
|
-
id: context.awsRequestId,
|
|
898
|
-
logger: PlatformServerlessTest.injector.logger,
|
|
899
|
-
injector: PlatformServerlessTest.injector,
|
|
900
|
-
endpoint
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
}
|
|
905
|
-
PlatformServerlessTest.callbacks = {};
|
|
906
|
-
PlatformServerlessTest.request = LambdaClientRequest;
|
|
907
|
-
|
|
908
|
-
/**
|
|
909
|
-
* Declare a lambda endpoint.
|
|
910
|
-
*
|
|
911
|
-
* ```typescript
|
|
912
|
-
* export class Lambda {
|
|
913
|
-
*
|
|
914
|
-
* }
|
|
915
|
-
* ```
|
|
916
|
-
*
|
|
917
|
-
* @decorator
|
|
918
|
-
*/
|
|
919
|
-
|
|
920
|
-
function Lambda(name) {
|
|
921
|
-
const options = {
|
|
922
|
-
path: "/",
|
|
923
|
-
method: "",
|
|
924
|
-
name
|
|
925
|
-
};
|
|
926
|
-
const decorator = schema.JsonEntityFn(entity => {
|
|
927
|
-
return core.useDecorators(schema.OperationPath(options.method, options.path), schema.OperationId(options.name || String(entity.propertyKey)));
|
|
928
|
-
});
|
|
929
|
-
|
|
930
|
-
decorator.Name = name => {
|
|
931
|
-
options.name = name;
|
|
932
|
-
return decorator;
|
|
933
|
-
};
|
|
934
|
-
|
|
935
|
-
decorator.Path = path => {
|
|
936
|
-
options.path = path;
|
|
937
|
-
return decorator;
|
|
938
|
-
};
|
|
939
|
-
|
|
940
|
-
decorator.Method = method => {
|
|
941
|
-
options.method = method;
|
|
942
|
-
return decorator;
|
|
943
|
-
};
|
|
944
|
-
|
|
945
|
-
return decorator;
|
|
946
|
-
}
|
|
947
|
-
/**
|
|
948
|
-
* @param path
|
|
949
|
-
* @decorators
|
|
950
|
-
* @ignore
|
|
951
|
-
*/
|
|
952
|
-
|
|
953
|
-
function Get(path = "/") {
|
|
954
|
-
return Lambda().Path(path).Method(schema.OperationMethods.GET);
|
|
955
|
-
}
|
|
956
|
-
/**
|
|
957
|
-
* @param path
|
|
958
|
-
* @decorators
|
|
959
|
-
* @ignore
|
|
960
|
-
*/
|
|
961
|
-
|
|
962
|
-
function Post(path = "/") {
|
|
963
|
-
return Lambda().Path(path).Method(schema.OperationMethods.POST);
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* @param path
|
|
967
|
-
* @decorators
|
|
968
|
-
* @ignore
|
|
969
|
-
*/
|
|
970
|
-
|
|
971
|
-
function Put(path = "/") {
|
|
972
|
-
return Lambda().Path(path).Method(schema.OperationMethods.PUT);
|
|
973
|
-
}
|
|
974
|
-
/**
|
|
975
|
-
* @param path
|
|
976
|
-
* @decorators
|
|
977
|
-
* @ignore
|
|
978
|
-
*/
|
|
979
|
-
|
|
980
|
-
function Patch(path = "/") {
|
|
981
|
-
return Lambda().Path(path).Method(schema.OperationMethods.PATCH);
|
|
982
|
-
}
|
|
983
|
-
/**
|
|
984
|
-
* @param path
|
|
985
|
-
* @decorators
|
|
986
|
-
* @ignore
|
|
987
|
-
*/
|
|
988
|
-
|
|
989
|
-
function Delete(path = "/") {
|
|
990
|
-
return Lambda().Path(path).Method(schema.OperationMethods.DELETE);
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
exports.Delete = Delete;
|
|
994
|
-
exports.Get = Get;
|
|
995
|
-
exports.Lambda = Lambda;
|
|
996
|
-
exports.LambdaClientRequest = LambdaClientRequest;
|
|
997
|
-
exports.Patch = Patch;
|
|
998
|
-
exports.PlatformServerless = PlatformServerless;
|
|
999
|
-
exports.PlatformServerlessTest = PlatformServerlessTest;
|
|
1000
|
-
exports.Post = Post;
|
|
1001
|
-
exports.Put = Put;
|
|
1002
|
-
exports.ServerlessContext = ServerlessContext;
|
|
1003
|
-
exports.ServerlessResponse = ServerlessResponse;
|
|
1004
|
-
Object.keys(di).forEach(function (k) {
|
|
1005
|
-
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
1006
|
-
enumerable: true,
|
|
1007
|
-
get: function () {
|
|
1008
|
-
return di[k];
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
});
|
|
1012
|
-
Object.keys(platformParams).forEach(function (k) {
|
|
1013
|
-
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
1014
|
-
enumerable: true,
|
|
1015
|
-
get: function () {
|
|
1016
|
-
return platformParams[k];
|
|
1017
|
-
}
|
|
1018
|
-
});
|
|
1019
|
-
});
|
|
1020
|
-
//# sourceMappingURL=index.js.map
|