@h4ad/serverless-adapter 2.8.0 → 2.10.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/lib/@types/digital-ocean/digital-ocean-http-event.d.ts +38 -0
- package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts.map +1 -0
- package/lib/@types/digital-ocean/digital-ocean-http-event.js +7 -0
- package/lib/@types/digital-ocean/digital-ocean-http-event.js.map +1 -0
- package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts +23 -0
- package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts.map +1 -0
- package/lib/@types/digital-ocean/digital-ocean-http-response.js +7 -0
- package/lib/@types/digital-ocean/digital-ocean-http-response.js.map +1 -0
- package/lib/@types/digital-ocean/index.d.ts +2 -0
- package/lib/@types/digital-ocean/index.d.ts.map +1 -0
- package/lib/@types/digital-ocean/index.js +18 -0
- package/lib/@types/digital-ocean/index.js.map +1 -0
- package/lib/adapters/aws/index.d.ts +1 -0
- package/lib/adapters/aws/index.d.ts.map +1 -1
- package/lib/adapters/aws/index.js +1 -0
- package/lib/adapters/aws/index.js.map +1 -1
- package/lib/adapters/aws/s3.adapter.d.ts +71 -0
- package/lib/adapters/aws/s3.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/s3.adapter.js +91 -0
- package/lib/adapters/aws/s3.adapter.js.map +1 -0
- package/lib/adapters/digital-ocean/http-function.adapter.d.ts +66 -0
- package/lib/adapters/digital-ocean/http-function.adapter.d.ts.map +1 -0
- package/lib/adapters/digital-ocean/http-function.adapter.js +118 -0
- package/lib/adapters/digital-ocean/http-function.adapter.js.map +1 -0
- package/lib/adapters/digital-ocean/index.d.ts +2 -0
- package/lib/adapters/digital-ocean/index.d.ts.map +1 -0
- package/lib/adapters/digital-ocean/index.js +18 -0
- package/lib/adapters/digital-ocean/index.js.map +1 -0
- package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts +17 -0
- package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts.map +1 -0
- package/lib/handlers/digital-ocean/digital-ocean.handler.js +34 -0
- package/lib/handlers/digital-ocean/digital-ocean.handler.js.map +1 -0
- package/lib/handlers/digital-ocean/index.d.ts +2 -0
- package/lib/handlers/digital-ocean/index.d.ts.map +1 -0
- package/lib/handlers/digital-ocean/index.js +18 -0
- package/lib/handlers/digital-ocean/index.js.map +1 -0
- package/lib/handlers/firebase/http-firebase.handler.d.ts.map +1 -1
- package/lib/handlers/firebase/http-firebase.handler.js +6 -1
- package/lib/handlers/firebase/http-firebase.handler.js.map +1 -1
- package/package.json +10 -7
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SingleValueHeaders } from '../headers';
|
|
2
|
+
/**
|
|
3
|
+
* The interface to represents the values of args send when someone calls a function using HTTP Endpoint.
|
|
4
|
+
* To be able to receive this event, inside your `project.yml`, instead of `web: true` change to `web: 'raw'`.
|
|
5
|
+
*
|
|
6
|
+
* {@link https://www.digitalocean.com/community/questions/digitalocean-functions-how-to-differentiate-query-params-from-body-params | Reference}
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @breadcrumb Types / Digital Ocean / DigitalOceanHttpEvent
|
|
10
|
+
*/
|
|
11
|
+
export interface DigitalOceanHttpEvent {
|
|
12
|
+
/**
|
|
13
|
+
* The HTTP Method of the request
|
|
14
|
+
*/
|
|
15
|
+
__ow_method: string;
|
|
16
|
+
/**
|
|
17
|
+
* The query porams of the request
|
|
18
|
+
*/
|
|
19
|
+
__ow_query: string;
|
|
20
|
+
/**
|
|
21
|
+
* The body of the request.
|
|
22
|
+
*/
|
|
23
|
+
__ow_body?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Indicates if body is base64 string
|
|
26
|
+
*/
|
|
27
|
+
__ow_isBase64Encoded?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The HTTP Headers of the request
|
|
30
|
+
*/
|
|
31
|
+
__ow_headers: SingleValueHeaders;
|
|
32
|
+
/**
|
|
33
|
+
* The path in the request
|
|
34
|
+
*/
|
|
35
|
+
__ow_path: string;
|
|
36
|
+
}
|
|
37
|
+
export declare type __ΩDigitalOceanHttpEvent = any[];
|
|
38
|
+
//# sourceMappingURL=digital-ocean-http-event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digital-ocean-http-event.d.ts","sourceRoot":"","sources":["../../../src/@types/digital-ocean/digital-ocean-http-event.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAIhD;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B;;OAEG;IACH,YAAY,EAAE,kBAAkB,CAAC;IAEjC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.__ΩDigitalOceanHttpEvent = void 0;
|
|
4
|
+
const { __ΩSingleValueHeaders } = require('../headers');
|
|
5
|
+
const __ΩDigitalOceanHttpEvent = ['__ow_method', '__ow_query', '__ow_body', '__ow_isBase64Encoded', () => __ΩSingleValueHeaders, '__ow_headers', '__ow_path', 'P&4!&4"&4#8)4$8n%4&&4\'M'];
|
|
6
|
+
exports.__ΩDigitalOceanHttpEvent = __ΩDigitalOceanHttpEvent;
|
|
7
|
+
//# sourceMappingURL=digital-ocean-http-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digital-ocean-http-event.js","sourceRoot":"","sources":["../../../src/@types/digital-ocean/digital-ocean-http-event.ts"],"names":[],"mappings":";;;0CAEmC,YAAY"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SingleValueHeaders } from '../headers';
|
|
2
|
+
/**
|
|
3
|
+
* The interface to represents the response of Digital Ocean Function.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
* @breadcrumb Types / Digital Ocean / DigitalOceanHttpResponse
|
|
7
|
+
*/
|
|
8
|
+
export interface DigitalOceanHttpResponse {
|
|
9
|
+
/**
|
|
10
|
+
* The HTTP Headers of the response
|
|
11
|
+
*/
|
|
12
|
+
headers?: SingleValueHeaders;
|
|
13
|
+
/**
|
|
14
|
+
* The body of the response
|
|
15
|
+
*/
|
|
16
|
+
body: unknown;
|
|
17
|
+
/**
|
|
18
|
+
* The HTTP Status code of the response
|
|
19
|
+
*/
|
|
20
|
+
statusCode: number;
|
|
21
|
+
}
|
|
22
|
+
export declare type __ΩDigitalOceanHttpResponse = any[];
|
|
23
|
+
//# sourceMappingURL=digital-ocean-http-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digital-ocean-http-response.d.ts","sourceRoot":"","sources":["../../../src/@types/digital-ocean/digital-ocean-http-response.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAE7B;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IAEd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.__ΩDigitalOceanHttpResponse = void 0;
|
|
4
|
+
const { __ΩSingleValueHeaders } = require('../headers');
|
|
5
|
+
const __ΩDigitalOceanHttpResponse = [() => __ΩSingleValueHeaders, 'headers', 'body', 'statusCode', 'Pn!4"8#4#\'4$M'];
|
|
6
|
+
exports.__ΩDigitalOceanHttpResponse = __ΩDigitalOceanHttpResponse;
|
|
7
|
+
//# sourceMappingURL=digital-ocean-http-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digital-ocean-http-response.js","sourceRoot":"","sources":["../../../src/@types/digital-ocean/digital-ocean-http-response.ts"],"names":[],"mappings":";;;0CAEmC,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/@types/digital-ocean/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./digital-ocean-http-event"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/@types/digital-ocean/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C"}
|
|
@@ -4,6 +4,7 @@ export * from './api-gateway-v2.adapter';
|
|
|
4
4
|
export * from './dynamodb.adapter';
|
|
5
5
|
export * from './event-bridge.adapter';
|
|
6
6
|
export * from './lambda-edge.adapter';
|
|
7
|
+
export * from './s3.adapter';
|
|
7
8
|
export * from './sns.adapter';
|
|
8
9
|
export * from './sqs.adapter';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
|
@@ -20,6 +20,7 @@ __exportStar(require("./api-gateway-v2.adapter"), exports);
|
|
|
20
20
|
__exportStar(require("./dynamodb.adapter"), exports);
|
|
21
21
|
__exportStar(require("./event-bridge.adapter"), exports);
|
|
22
22
|
__exportStar(require("./lambda-edge.adapter"), exports);
|
|
23
|
+
__exportStar(require("./s3.adapter"), exports);
|
|
23
24
|
__exportStar(require("./sns.adapter"), exports);
|
|
24
25
|
__exportStar(require("./sqs.adapter"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/aws/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,2DAAyC;AACzC,2DAAyC;AACzC,qDAAmC;AACnC,yDAAuC;AACvC,wDAAsC;AACtC,gDAA8B;AAC9B,gDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/aws/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,2DAAyC;AACzC,2DAAyC;AACzC,qDAAmC;AACnC,yDAAuC;AACvC,wDAAsC;AACtC,+CAA6B;AAC7B,gDAA8B;AAC9B,gDAA8B"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Context, S3Event } from 'aws-lambda';
|
|
2
|
+
import { AdapterContract, AdapterRequest, OnErrorProps } from '../../contracts';
|
|
3
|
+
import { IEmptyResponse } from '../../core';
|
|
4
|
+
/**
|
|
5
|
+
* The options to customize the {@link S3Adapter}
|
|
6
|
+
*
|
|
7
|
+
* @breadcrumb Adapters / AWS / S3Adapter
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface S3AdapterOptions {
|
|
11
|
+
/**
|
|
12
|
+
* The path that will be used to create a request to be forwarded to the framework.
|
|
13
|
+
*
|
|
14
|
+
* @defaultValue /s3
|
|
15
|
+
*/
|
|
16
|
+
s3ForwardPath?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The http method that will be used to create a request to be forwarded to the framework.
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue POST
|
|
21
|
+
*/
|
|
22
|
+
s3ForwardMethod?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The adapter to handle requests from AWS S3.
|
|
26
|
+
*
|
|
27
|
+
* The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.
|
|
28
|
+
*
|
|
29
|
+
* {@link https://docs.aws.amazon.com/pt_br/lambda/latest/dg/with-s3.html | Event Reference}
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const s3ForwardPath = '/your/route/s3'; // default /s3
|
|
34
|
+
* const s3ForwardMethod = 'POST'; // default POST
|
|
35
|
+
* const adapter = new S3Adapter({ s3ForwardPath, s3ForwardMethod });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @breadcrumb Adapters / AWS / S3Adapter
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare class S3Adapter implements AdapterContract<S3Event, Context, IEmptyResponse> {
|
|
42
|
+
protected readonly options?: S3AdapterOptions | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Default constructor
|
|
45
|
+
*
|
|
46
|
+
* @param options - The options to customize the {@link S3Adapter}
|
|
47
|
+
*/
|
|
48
|
+
constructor(options?: S3AdapterOptions | undefined);
|
|
49
|
+
/**
|
|
50
|
+
* {@inheritDoc}
|
|
51
|
+
*/
|
|
52
|
+
getAdapterName(): string;
|
|
53
|
+
/**
|
|
54
|
+
* {@inheritDoc}
|
|
55
|
+
*/
|
|
56
|
+
canHandle(event: unknown): event is S3Event;
|
|
57
|
+
/**
|
|
58
|
+
* {@inheritDoc}
|
|
59
|
+
*/
|
|
60
|
+
getRequest(event: S3Event): AdapterRequest;
|
|
61
|
+
/**
|
|
62
|
+
* {@inheritDoc}
|
|
63
|
+
*/
|
|
64
|
+
getResponse(): IEmptyResponse;
|
|
65
|
+
/**
|
|
66
|
+
* {@inheritDoc}
|
|
67
|
+
*/
|
|
68
|
+
onErrorWhileForwarding({ error, delegatedResolver, }: OnErrorProps<S3Event, IEmptyResponse>): void;
|
|
69
|
+
}
|
|
70
|
+
export declare type __ΩS3AdapterOptions = any[];
|
|
71
|
+
//# sourceMappingURL=s3.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s3.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/s3.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAEL,cAAc,EAGf,MAAM,YAAY,CAAC;AAIpB;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,SACX,YAAW,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,CAAC;IAShD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC;IALvC;;;;OAIG;gBAC4B,OAAO,CAAC,8BAAkB;IAMzD;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO;IAUlD;;OAEG;IACI,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc;IAuBjD;;OAEG;IACI,WAAW,IAAI,cAAc;IAIpC;;OAEG;IACI,sBAAsB,CAAC,EAC5B,KAAK,EACL,iBAAiB,GAClB,EAAE,YAAY,CAAC,OAAO,EAAE,cAAc,CAAC,GAAG,IAAI;CAKhD"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.S3Adapter = exports.__ΩS3AdapterOptions = void 0;
|
|
4
|
+
const { __ΩAdapterRequest } = require('../../contracts');
|
|
5
|
+
const { __ΩIEmptyResponse } = require('../../core');
|
|
6
|
+
const { __ΩOnErrorProps } = require('../../contracts');
|
|
7
|
+
const core_1 = require("../../core");
|
|
8
|
+
const __ΩS3AdapterOptions = ['s3ForwardPath', 's3ForwardMethod', 'P&4!8&4"8M'];
|
|
9
|
+
exports.__ΩS3AdapterOptions = __ΩS3AdapterOptions;
|
|
10
|
+
/**
|
|
11
|
+
* The adapter to handle requests from AWS S3.
|
|
12
|
+
*
|
|
13
|
+
* The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.
|
|
14
|
+
*
|
|
15
|
+
* {@link https://docs.aws.amazon.com/pt_br/lambda/latest/dg/with-s3.html | Event Reference}
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const s3ForwardPath = '/your/route/s3'; // default /s3
|
|
20
|
+
* const s3ForwardMethod = 'POST'; // default POST
|
|
21
|
+
* const adapter = new S3Adapter({ s3ForwardPath, s3ForwardMethod });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @breadcrumb Adapters / AWS / S3Adapter
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
class S3Adapter {
|
|
28
|
+
//#region Constructor
|
|
29
|
+
/**
|
|
30
|
+
* Default constructor
|
|
31
|
+
*
|
|
32
|
+
* @param options - The options to customize the {@link S3Adapter}
|
|
33
|
+
*/
|
|
34
|
+
constructor(options) {
|
|
35
|
+
this.options = options;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region Public Methods
|
|
39
|
+
/**
|
|
40
|
+
* {@inheritDoc}
|
|
41
|
+
*/
|
|
42
|
+
getAdapterName() {
|
|
43
|
+
return S3Adapter.name;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* {@inheritDoc}
|
|
47
|
+
*/
|
|
48
|
+
canHandle(event) {
|
|
49
|
+
var _a;
|
|
50
|
+
const s3Event = event;
|
|
51
|
+
if (!Array.isArray(s3Event === null || s3Event === void 0 ? void 0 : s3Event.Records))
|
|
52
|
+
return false;
|
|
53
|
+
const eventSource = (_a = s3Event.Records[0]) === null || _a === void 0 ? void 0 : _a.eventSource;
|
|
54
|
+
return eventSource === 'aws:s3';
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* {@inheritDoc}
|
|
58
|
+
*/
|
|
59
|
+
getRequest(event) {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const path = (0, core_1.getDefaultIfUndefined)((_a = this.options) === null || _a === void 0 ? void 0 : _a.s3ForwardPath, '/s3');
|
|
62
|
+
const method = (0, core_1.getDefaultIfUndefined)((_b = this.options) === null || _b === void 0 ? void 0 : _b.s3ForwardMethod, 'POST');
|
|
63
|
+
const [body, contentLength] = (0, core_1.getEventBodyAsBuffer)(JSON.stringify(event), false);
|
|
64
|
+
const headers = {
|
|
65
|
+
host: 's3.amazonaws.com',
|
|
66
|
+
'content-type': 'application/json',
|
|
67
|
+
'content-length': String(contentLength),
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
method,
|
|
71
|
+
headers,
|
|
72
|
+
body,
|
|
73
|
+
path,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* {@inheritDoc}
|
|
78
|
+
*/
|
|
79
|
+
getResponse() {
|
|
80
|
+
return core_1.EmptyResponse;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* {@inheritDoc}
|
|
84
|
+
*/
|
|
85
|
+
onErrorWhileForwarding({ error, delegatedResolver, }) {
|
|
86
|
+
delegatedResolver.fail(error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.S3Adapter = S3Adapter;
|
|
90
|
+
S3Adapter.__type = [() => __ΩS3AdapterOptions, 'options', 'constructor', 'getAdapterName', 'event', 'canHandle', () => __ΩAdapterRequest, 'getRequest', () => __ΩIEmptyResponse, 'getResponse', () => __ΩOnErrorProps, () => __ΩIEmptyResponse, 'param0', 'onErrorWhileForwarding', () => __ΩIEmptyResponse, 'Pn!2"8<9"0#P&0$P#2%!0&P"2%n\'0(Pn)0*P"n,o+#2-$0.5""n/6$'];
|
|
91
|
+
//# sourceMapp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AClC,gBAAgB,EAAE,MAAM,CAAC,aAAa,CAAC;SACxC,CAAC;QAEF,OAAO;YACL,MAAM;YACN,OAAO;YACP,IAAI;YACJ,IAAI;SACL,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,WAAW;QAChB,OAAO,oBAAa,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,sBAAsB,CAAC,EAC5B,KAAK,EACL,iBAAiB,GACqB;QACtC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;;AA7EH,8BAgFC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { DigitalOceanHttpEvent } from '../../@types/digital-ocean';
|
|
2
|
+
import { DigitalOceanHttpResponse } from '../../@types/digital-ocean/digital-ocean-http-response';
|
|
3
|
+
import { AdapterContract, AdapterRequest, GetResponseAdapterProps, OnErrorProps } from '../../contracts';
|
|
4
|
+
/**
|
|
5
|
+
* The options to customize the {@link HttpFunctionAdapter}
|
|
6
|
+
*
|
|
7
|
+
* @breadcrumb Adapters / Digital Ocean / HttpFunctionAdapter
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export interface HttpFunctionAdapterOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Strip base path for custom domains
|
|
13
|
+
*
|
|
14
|
+
* @defaultValue ''
|
|
15
|
+
*/
|
|
16
|
+
stripBasePath?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The adapter to handle requests from Digital Ocean Functions when called from HTTP Endpoint.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const stripBasePath = '/any/custom/base/path'; // default ''
|
|
24
|
+
* const adapter = new HttpFunctionAdapter({ stripBasePath });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @breadcrumb Adapters / Digital Ocean / HttpFunctionAdapter
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare class HttpFunctionAdapter implements AdapterContract<DigitalOceanHttpEvent, void, DigitalOceanHttpResponse> {
|
|
31
|
+
protected readonly options?: HttpFunctionAdapterOptions | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Default constructor
|
|
34
|
+
*
|
|
35
|
+
* @param options - The options to customize the {@link HttpFunctionAdapter}
|
|
36
|
+
*/
|
|
37
|
+
constructor(options?: HttpFunctionAdapterOptions | undefined);
|
|
38
|
+
/**
|
|
39
|
+
* {@inheritDoc}
|
|
40
|
+
*/
|
|
41
|
+
getAdapterName(): string;
|
|
42
|
+
/**
|
|
43
|
+
* {@inheritDoc}
|
|
44
|
+
*/
|
|
45
|
+
canHandle(event: unknown): event is DigitalOceanHttpEvent;
|
|
46
|
+
/**
|
|
47
|
+
* {@inheritDoc}
|
|
48
|
+
*/
|
|
49
|
+
getRequest(event: DigitalOceanHttpEvent): AdapterRequest;
|
|
50
|
+
/**
|
|
51
|
+
* {@inheritDoc}
|
|
52
|
+
*/
|
|
53
|
+
getResponse({ headers: responseHeaders, body, statusCode, }: GetResponseAdapterProps<DigitalOceanHttpEvent>): DigitalOceanHttpResponse;
|
|
54
|
+
/**
|
|
55
|
+
* {@inheritDoc}
|
|
56
|
+
*/
|
|
57
|
+
onErrorWhileForwarding({ error, delegatedResolver, respondWithErrors, event, log, }: OnErrorProps<DigitalOceanHttpEvent, DigitalOceanHttpResponse>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Get path from event with query strings
|
|
60
|
+
*
|
|
61
|
+
* @param event - The event sent by digital ocean
|
|
62
|
+
*/
|
|
63
|
+
protected getPathFromEvent(event: DigitalOceanHttpEvent): string;
|
|
64
|
+
}
|
|
65
|
+
export declare type __ΩHttpFunctionAdapterOptions = any[];
|
|
66
|
+
//# sourceMappingURL=http-function.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-function.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/digital-ocean/http-function.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wDAAwD,CAAC;AAClG,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,YAAY,EACb,MAAM,iBAAiB,CAAC;AAUzB;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,mBACX,YACE,eAAe,CAAC,qBAAqB,EAAE,IAAI,EAAE,wBAAwB,CAAC;IAS5D,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC;IALvC;;;;OAIG;gBAC4B,OAAO,CAAC,wCAA4B;IAMnE;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB;IAWhE;;OAEG;IACI,UAAU,CAAC,KAAK,EAAE,qBAAqB,GAAG,cAAc;IA4B/D;;OAEG;IACI,WAAW,CAAC,EACjB,OAAO,EAAE,eAAe,EACxB,IAAI,EACJ,UAAU,GACX,EAAE,uBAAuB,CAAC,qBAAqB,CAAC,GAAG,wBAAwB;IAU5E;;OAEG;IACI,sBAAsB,CAAC,EAC5B,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,EACL,GAAG,GACJ,EAAE,YAAY,CAAC,qBAAqB,EAAE,wBAAwB,CAAC,GAAG,IAAI;IAkBvE;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM;CAcjE"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpFunctionAdapter = exports.__ΩHttpFunctionAdapterOptions = void 0;
|
|
4
|
+
const { __ΩDigitalOceanHttpEvent } = require('../../@types/digital-ocean');
|
|
5
|
+
const { __ΩAdapterRequest } = require('../../contracts');
|
|
6
|
+
const { __ΩGetResponseAdapterProps } = require('../../contracts');
|
|
7
|
+
const { __ΩDigitalOceanHttpResponse } = require('../../@types/digital-ocean/digital-ocean-http-response');
|
|
8
|
+
const { __ΩOnErrorProps } = require('../../contracts');
|
|
9
|
+
const core_1 = require("../../core");
|
|
10
|
+
const __ΩHttpFunctionAdapterOptions = ['stripBasePath', 'P&4!8M'];
|
|
11
|
+
exports.__ΩHttpFunctionAdapterOptions = __ΩHttpFunctionAdapterOptions;
|
|
12
|
+
/**
|
|
13
|
+
* The adapter to handle requests from Digital Ocean Functions when called from HTTP Endpoint.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const stripBasePath = '/any/custom/base/path'; // default ''
|
|
18
|
+
* const adapter = new HttpFunctionAdapter({ stripBasePath });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @breadcrumb Adapters / Digital Ocean / HttpFunctionAdapter
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
class HttpFunctionAdapter {
|
|
25
|
+
//#region Constructor
|
|
26
|
+
/**
|
|
27
|
+
* Default constructor
|
|
28
|
+
*
|
|
29
|
+
* @param options - The options to customize the {@link HttpFunctionAdapter}
|
|
30
|
+
*/
|
|
31
|
+
constructor(options) {
|
|
32
|
+
this.options = options;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region Public Methods
|
|
36
|
+
/**
|
|
37
|
+
* {@inheritDoc}
|
|
38
|
+
*/
|
|
39
|
+
getAdapterName() {
|
|
40
|
+
return HttpFunctionAdapter.name;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* {@inheritDoc}
|
|
44
|
+
*/
|
|
45
|
+
canHandle(event) {
|
|
46
|
+
const digitalOceanHttpEvent = event;
|
|
47
|
+
return (!!digitalOceanHttpEvent &&
|
|
48
|
+
digitalOceanHttpEvent.__ow_path !== undefined &&
|
|
49
|
+
digitalOceanHttpEvent.__ow_method !== undefined &&
|
|
50
|
+
digitalOceanHttpEvent.__ow_headers !== undefined);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* {@inheritDoc}
|
|
54
|
+
*/
|
|
55
|
+
getRequest(event) {
|
|
56
|
+
const headers = event.__ow_headers;
|
|
57
|
+
const method = event.__ow_method.toUpperCase();
|
|
58
|
+
const path = this.getPathFromEvent(event);
|
|
59
|
+
let body;
|
|
60
|
+
if (event.__ow_body) {
|
|
61
|
+
const [bufferBody, contentLength] = (0, core_1.getEventBodyAsBuffer)(event.__ow_body, !!event.__ow_isBase64Encoded);
|
|
62
|
+
body = bufferBody;
|
|
63
|
+
headers['content-length'] = String(contentLength);
|
|
64
|
+
}
|
|
65
|
+
const remoteAddress = headers['x-forwarded-for'];
|
|
66
|
+
return {
|
|
67
|
+
method,
|
|
68
|
+
headers,
|
|
69
|
+
body,
|
|
70
|
+
remoteAddress,
|
|
71
|
+
path,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* {@inheritDoc}
|
|
76
|
+
*/
|
|
77
|
+
getResponse({ headers: responseHeaders, body, statusCode, }) {
|
|
78
|
+
const headers = (0, core_1.getFlattenedHeadersMap)(responseHeaders);
|
|
79
|
+
return {
|
|
80
|
+
statusCode,
|
|
81
|
+
body,
|
|
82
|
+
headers,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* {@inheritDoc}
|
|
87
|
+
*/
|
|
88
|
+
onErrorWhileForwarding({ error, delegatedResolver, respondWithErrors, event, log, }) {
|
|
89
|
+
const body = respondWithErrors ? error.stack : '';
|
|
90
|
+
const errorResponse = this.getResponse({
|
|
91
|
+
event,
|
|
92
|
+
statusCode: 500,
|
|
93
|
+
body: body || '',
|
|
94
|
+
headers: {},
|
|
95
|
+
isBase64Encoded: false,
|
|
96
|
+
log,
|
|
97
|
+
});
|
|
98
|
+
delegatedResolver.succeed(errorResponse);
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region Protected Methods
|
|
102
|
+
/**
|
|
103
|
+
* Get path from event with query strings
|
|
104
|
+
*
|
|
105
|
+
* @param event - The event sent by digital ocean
|
|
106
|
+
*/
|
|
107
|
+
getPathFromEvent(event) {
|
|
108
|
+
var _a;
|
|
109
|
+
const stripBasePath = (0, core_1.getDefaultIfUndefined)((_a = this.options) === null || _a === void 0 ? void 0 : _a.stripBasePath, '');
|
|
110
|
+
const replaceRegex = new RegExp(`^${stripBasePath}`);
|
|
111
|
+
const path = event.__ow_path.replace(replaceRegex, '');
|
|
112
|
+
const queryParams = event.__ow_query;
|
|
113
|
+
return (0, core_1.getPathWithQueryStringParams)(path, queryParams || {});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.HttpFunctionAdapter = HttpFunctionAdapter;
|
|
117
|
+
HttpFunctionAdapter.__type = [() => __ΩHttpFunctionAdapterOptions, 'options', 'constructor', 'getAdapterName', 'event', 'canHandle', () => __ΩDigitalOceanHttpEvent, () => __ΩAdapterRequest, 'getRequest', () => __ΩGetResponseAdapterProps, () => __ΩDigitalOceanHttpEvent, 'param0', () => __ΩDigitalOceanHttpResponse, 'getResponse', () => __ΩOnErrorProps, () => __ΩDigitalOceanHttpEvent, () => __ΩDigitalOceanHttpResponse, 'onErrorWhileForwarding', () => __ΩDigitalOceanHttpEvent, 'getPathFromEvent', () => __ΩDigitalOceanHttpEvent, () => __ΩDigitalOceanHttpResponse, 'Pn!2"8<9"0#P&0$P#2%!0&Pn\'2%n(0)Pn+o*"2,n-0.Pn0n1o/#2,$02Pn32%&04<5n5$n66$'];
|
|
118
|
+
//# sourceMappingURL=http-function.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-function.adapter.js","sourceRoot":"","sources":["../../../src/adapters/digital-ocean/http-function.adapter.ts"],"names":[],"mappings":";;;6CAEs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
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/digital-ocean/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./http-function.adapter"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/digital-ocean/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BinarySettings } from '../../@types';
|
|
2
|
+
import { AdapterContract, FrameworkContract, ResolverContract, ServerlessHandler } from '../../contracts';
|
|
3
|
+
import { ILogger } from '../../core';
|
|
4
|
+
import { DefaultHandler } from '../default';
|
|
5
|
+
/**
|
|
6
|
+
* The class that implements a serverless handler for Digital Ocean Functions.
|
|
7
|
+
*
|
|
8
|
+
* @breadcrumb Handlers / DigitalOceanHandler
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare class DigitalOceanHandler<TApp, TEvent, TResponse, TReturn> extends DefaultHandler<TApp, TEvent, void, void, TResponse, TReturn> {
|
|
12
|
+
/**
|
|
13
|
+
* {@inheritDoc}
|
|
14
|
+
*/
|
|
15
|
+
getHandler(app: TApp, framework: FrameworkContract<TApp>, adapters: AdapterContract<TEvent, void, TResponse>[], resolverFactory: ResolverContract<TEvent, void, void, TResponse, TReturn>, binarySettings: BinarySettings, respondWithErrors: boolean, log: ILogger): ServerlessHandler<TReturn>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=digital-ocean.handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digital-ocean.handler.d.ts","sourceRoot":"","sources":["../../../src/handlers/digital-ocean/digital-ocean.handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAI5C;;;;;GAKG;AACH,qBAAa,mBAAmB,CAC9B,IAAI,EACJ,MAAM,EACN,SAAS,EACT,OAAO,CACP,SAAQ,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;IACpE;;OAEG;IACI,UAAU,CACf,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAClC,QAAQ,EAAE,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,EACpD,eAAe,EAAE,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EACzE,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,OAAO,EAC1B,GAAG,EAAE,OAAO,GACX,iBAAiB,CAAC,OAAO,CAAC;CAc9B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DigitalOceanHandler = void 0;
|
|
4
|
+
const { __ΩDigitalOceanHttpEvent } = require('../../@types/digital-ocean');
|
|
5
|
+
const { __ΩFrameworkContract } = require('../../contracts');
|
|
6
|
+
const { __ΩAdapterContract } = require('../../contracts');
|
|
7
|
+
const { __ΩResolverContract } = require('../../contracts');
|
|
8
|
+
const { __ΩBinarySettings } = require('../../@types');
|
|
9
|
+
const { __ΩILogger } = require('../../core');
|
|
10
|
+
const { __ΩServerlessHandler } = require('../../contracts');
|
|
11
|
+
function __assignType(fn, args) {
|
|
12
|
+
fn.__type = args;
|
|
13
|
+
return fn;
|
|
14
|
+
}
|
|
15
|
+
const default_1 = require("../default");
|
|
16
|
+
//#endregion
|
|
17
|
+
/**
|
|
18
|
+
* The class that implements a serverless handler for Digital Ocean Functions.
|
|
19
|
+
*
|
|
20
|
+
* @breadcrumb Handlers / DigitalOceanHandler
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
class DigitalOceanHandler extends default_1.DefaultHandler {
|
|
24
|
+
/**
|
|
25
|
+
* {@inheritDoc}
|
|
26
|
+
*/
|
|
27
|
+
getHandler(app, framework, adapters, resolverFactory, binarySettings, respondWithErrors, log) {
|
|
28
|
+
const defaultHandler = super.getHandler(app, framework, adapters, resolverFactory, binarySettings, respondWithErrors, log);
|
|
29
|
+
return __assignType((event) => defaultHandler(event, undefined, undefined), [() => __ΩDigitalOceanHttpEvent, 'event', '', 'Pn!2""/#']);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.DigitalOceanHandler = DigitalOceanHandler;
|
|
33
|
+
DigitalOceanHandler.__type = ['TApp', 'TEvent', 'TResponse', 'TReturn', () => default_1.DefaultHandler, 'app', () => __ΩFrameworkContract, 'framework', () => __ΩAdapterContract, 'adapters', () => __ΩResolverContract, 'resolverFactory', () => __ΩBinarySettings, 'binarySettings', 'respondWithErrors', () => __ΩILogger, 'log', () => __ΩServerlessHandler, 'getHandler', 'b!b"b#b$Pe"!e""$$e"#e"$7%Pe"!2&e"!o\'"2(e""$e"#o)$F2*e""$$e"#e"$o+&2,n-2.)2/n021e"$o2"035e!!e!"$$e!#e!$6\''];
|
|
34
|
+
//# sourceMappingURL=digital-ocean.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"digital-ocean.handler.js","sourceRoot":"","sources":["../../../src/handlers/digital-ocean/digital-ocean.handler.ts"],"names":[],"mappings":";;;6CAIsC,4BAA4B;yCAM3D,iBAAiB;uCAAjB,iBAAiB;wCAAjB,iBAAiB;sCAPO,cAAc;+BAQrB,YAAY;yCAD7B,iBAAiB;;;;;AAExB,wCAA4C;AAE5C,YAAY;AAEZ;;;;;GAKG;AACH,MAAa,mBAKX,SAAQ,wBAA4D;IACpE;;OAEG;IACI,UAAU,CACf,GAAS,EACT,SAAkC,EAClC,QAAoD,EACpD,eAAyE,EACzE,cAA8B,EAC9B,iBAA0B,EAC1B,GAAY;QAEZ,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CACrC,GAAG,EACH,SAAS,EACT,QAAQ,EACR,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,GAAG,CACJ,CAAC;QAEF,oBAAO,CAAC,KAA4B,EAAE,EAAE,CACtC,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,6DAAC;IAChD,CAAC;;AA9BH,kDA+BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/handlers/digital-ocean/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./digital-ocean.handler"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/handlers/digital-ocean/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-firebase.handler.d.ts","sourceRoot":"","sources":["../../../src/handlers/firebase/http-firebase.handler.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"http-firebase.handler.d.ts","sourceRoot":"","sources":["../../../src/handlers/firebase/http-firebase.handler.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAKrE;;;;;;;GAOG;AACH,qBAAa,mBAAmB,CAAC,IAAI,CACnC,YACE,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAIxE;;OAEG;IACI,UAAU,CACf,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC,GACjC,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAqBvE"}
|
|
@@ -23,7 +23,12 @@ class HttpFirebaseHandler {
|
|
|
23
23
|
*/
|
|
24
24
|
getHandler(app, framework) {
|
|
25
25
|
return firebase_functions_1.https.onRequest(__assignType((request, response) => {
|
|
26
|
-
|
|
26
|
+
const serverlessRequest = request;
|
|
27
|
+
if (serverlessRequest.body &&
|
|
28
|
+
typeof serverlessRequest.body === 'object') {
|
|
29
|
+
serverlessRequest.body = Buffer.from(JSON.stringify(serverlessRequest.body), 'utf-8');
|
|
30
|
+
}
|
|
31
|
+
return framework.sendRequest(app, serverlessRequest, response);
|
|
27
32
|
}, ['request', 'response', '', 'P!2!!2""/#']));
|
|
28
33
|
}
|
|
29
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-firebase.handler.js","sourceRoot":"","sources":["../../../src/handlers/firebase/http-firebase.handler.ts"],"names":[],"mappings":";;;yCAImD,iBAAiB;;;;;AADpE,2DAA2C;
|
|
1
|
+
{"version":3,"file":"http-firebase.handler.js","sourceRoot":"","sources":["../../../src/handlers/firebase/http-firebase.handler.ts"],"names":[],"mappings":";;;yCAImD,iBAAiB;;;;;AADpE,2DAA2C;AAI3C,YAAY;AAEZ;;;;;;;GAOG;AACH,MAAa,mBAAmB;IAI9B,wBAAwB;IAExB;;OAEG;IACI,UAAU,CACf,GAAS,EACT,SAAkC;QAElC,OAAO,0BAAK,CAAC,SAAS,cACpB,CAAC,OAAwB,EAAE,QAAwB,EAAE,EAAE;YACrD,MAAM,iBAAiB,GAAG,OAA4B,CAAC;YAEvD,IACE,iBAAiB,CAAC,IAAI;gBACtB,OAAO,iBAAiB,CAAC,IAAI,KAAK,QAAQ,EAC1C;gBACA,iBAAiB,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAClC,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,EACtC,OAAO,CACR,CAAC;aACH;YAED,OAAO,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QACjE,CAAC,6CACF,CAAC;IACJ,CAAC;;AA9BH,kDAiCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h4ad/serverless-adapter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Run REST APIs and other web applications using your existing Node.js application framework (NestJS, Express, Koa, Hapi, Fastify and many others), on top of AWS, Azure, Huawei and many other clouds.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"api gateway",
|
|
43
43
|
"sqs",
|
|
44
44
|
"sns",
|
|
45
|
-
"lambda
|
|
45
|
+
"lambda edge",
|
|
46
46
|
"alb",
|
|
47
47
|
"lambda",
|
|
48
48
|
"express",
|
|
@@ -55,13 +55,16 @@
|
|
|
55
55
|
"functiongraph",
|
|
56
56
|
"trpc",
|
|
57
57
|
"azure",
|
|
58
|
-
"azure
|
|
59
|
-
"http
|
|
58
|
+
"azure functions",
|
|
59
|
+
"http trigger v4",
|
|
60
60
|
"firebase",
|
|
61
|
-
"firebase
|
|
62
|
-
"firebase
|
|
61
|
+
"firebase functions",
|
|
62
|
+
"firebase http events",
|
|
63
63
|
"deepkit",
|
|
64
|
-
"deepkit http"
|
|
64
|
+
"deepkit http",
|
|
65
|
+
"digital ocean",
|
|
66
|
+
"digital ocean functions",
|
|
67
|
+
"digital ocean serverless"
|
|
65
68
|
],
|
|
66
69
|
"bugs": {
|
|
67
70
|
"url": "https://github.com/H4ad/serverless-adapter/issues"
|