@h4ad/serverless-adapter 2.14.0 → 2.15.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/core/headers.js +1 -1
- package/lib/core/headers.js.map +1 -1
- package/lib/handlers/base/index.d.ts +1 -0
- package/lib/handlers/base/index.js +18 -0
- package/lib/handlers/base/index.js.map +1 -0
- package/lib/handlers/base/raw-request.d.ts +30 -0
- package/lib/handlers/base/raw-request.js +65 -0
- package/lib/handlers/base/raw-request.js.map +1 -0
- package/lib/handlers/firebase/http-firebase.handler.d.ts +2 -1
- package/lib/handlers/firebase/http-firebase.handler.js +4 -29
- package/lib/handlers/firebase/http-firebase.handler.js.map +1 -1
- package/lib/handlers/gcp/gcp.handler.d.ts +25 -0
- package/lib/handlers/gcp/gcp.handler.js +40 -0
- package/lib/handlers/gcp/gcp.handler.js.map +1 -0
- package/lib/handlers/gcp/index.d.ts +1 -0
- package/lib/handlers/gcp/index.js +18 -0
- package/lib/handlers/gcp/index.js.map +1 -0
- package/package.json +9 -2
package/lib/core/headers.js
CHANGED
|
@@ -30,7 +30,7 @@ function getFlattenedHeadersMap(headersMap, separator = ',', lowerCaseKey = fals
|
|
|
30
30
|
if (Array.isArray(headerValue))
|
|
31
31
|
commaDelimitedHeaders[newKey] = headerValue.join(separator);
|
|
32
32
|
else
|
|
33
|
-
commaDelimitedHeaders[newKey] = headerValue
|
|
33
|
+
commaDelimitedHeaders[newKey] = String(headerValue !== null && headerValue !== void 0 ? headerValue : '');
|
|
34
34
|
}
|
|
35
35
|
return commaDelimitedHeaders;
|
|
36
36
|
}
|
package/lib/core/headers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../src/core/headers.ts"],"names":[],"mappings":";;;wCAEiC,WAAW;;AAE5C,YAAY;AAEZ;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,sBAAsB,CACpC,UAA4B,EAC5B,YAAoB,GAAG,EACvB,eAAwB,KAAK;IAE7B,MAAM,qBAAqB,GAA2B,EAAE,CAAC;IACzD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAErD,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,iBAAiB,EAAE;QACxD,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAElE,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;YAC5B,qBAAqB,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;;YACzD,qBAAqB,CAAC,MAAM,CAAC,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../src/core/headers.ts"],"names":[],"mappings":";;;wCAEiC,WAAW;;AAE5C,YAAY;AAEZ;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,sBAAsB,CACpC,UAA4B,EAC5B,YAAoB,GAAG,EACvB,eAAwB,KAAK;IAE7B,MAAM,qBAAqB,GAA2B,EAAE,CAAC;IACzD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAErD,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,iBAAiB,EAAE;QACxD,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAElE,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;YAC5B,qBAAqB,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;;YACzD,qBAAqB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC,CAAC;KAChE;IAED,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAjBD,wDAiBC;;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,uBAAuB,CACrC,UAA4B;IAE5B,MAAM,iBAAiB,GAA6B,EAAE,CAAC;IACvD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAErD,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,iBAAiB,EAAE;QACxD,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;YACrE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;YACzB,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;KAC3B;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAbD,0DAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './raw-request';
|
|
@@ -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("./raw-request"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/handlers/base/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
import { FrameworkContract } from '../../contracts/index';
|
|
4
|
+
import { ServerlessRequest } from '../../network/index';
|
|
5
|
+
/**
|
|
6
|
+
* The class that expose some methods to be used to get raw request from Express HTTP Request
|
|
7
|
+
*
|
|
8
|
+
* @breadcrumb Handlers / Base / RawRequest
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class RawRequest<TApp> {
|
|
12
|
+
/**
|
|
13
|
+
* The callback to when receive some request from external source
|
|
14
|
+
*
|
|
15
|
+
* @param app - The instance of the app
|
|
16
|
+
* @param framework - The framework for the app
|
|
17
|
+
*/
|
|
18
|
+
protected onRequestCallback(app: TApp, framework: FrameworkContract<TApp>): (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Not sure why they think using Express instance with prebuilt middlewares was a good idea, but Firebase/GCP
|
|
21
|
+
* decides to use `Express` and `body-parser` by default, so you don't get a raw request, instead, you get a modified version by
|
|
22
|
+
* Express and also with the body parsed by `body-parser`.
|
|
23
|
+
* If you use NestJS or Express it's awesome, but for the rest of the frameworks it's terrible!
|
|
24
|
+
* That's why I have this method, just to try and create a raw request to be used and passed to the frameworks so they can handle the request
|
|
25
|
+
* as if they received the request from the native http module.
|
|
26
|
+
*
|
|
27
|
+
* @param request - The Express request
|
|
28
|
+
*/
|
|
29
|
+
protected getRequestFromExpressRequest(request: IncomingMessage): ServerlessRequest;
|
|
30
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RawRequest = void 0;
|
|
4
|
+
const { __ΩFrameworkContract } = require('../../contracts/index');
|
|
5
|
+
function __assignType(fn, args) {
|
|
6
|
+
fn.__type = args;
|
|
7
|
+
return fn;
|
|
8
|
+
}
|
|
9
|
+
const index_1 = require("../../network/index");
|
|
10
|
+
const index_2 = require("../../core/index");
|
|
11
|
+
//#endregion
|
|
12
|
+
/**
|
|
13
|
+
* The class that expose some methods to be used to get raw request from Express HTTP Request
|
|
14
|
+
*
|
|
15
|
+
* @breadcrumb Handlers / Base / RawRequest
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
class RawRequest {
|
|
19
|
+
//#region Protected Methods
|
|
20
|
+
/**
|
|
21
|
+
* The callback to when receive some request from external source
|
|
22
|
+
*
|
|
23
|
+
* @param app - The instance of the app
|
|
24
|
+
* @param framework - The framework for the app
|
|
25
|
+
*/
|
|
26
|
+
onRequestCallback(app, framework) {
|
|
27
|
+
return __assignType((request, response) => {
|
|
28
|
+
const customRequest = this.getRequestFromExpressRequest(request);
|
|
29
|
+
return framework.sendRequest(app, customRequest, response);
|
|
30
|
+
}, ['request', 'response', '', 'P!2!!2""/#']);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Not sure why they think using Express instance with prebuilt middlewares was a good idea, but Firebase/GCP
|
|
34
|
+
* decides to use `Express` and `body-parser` by default, so you don't get a raw request, instead, you get a modified version by
|
|
35
|
+
* Express and also with the body parsed by `body-parser`.
|
|
36
|
+
* If you use NestJS or Express it's awesome, but for the rest of the frameworks it's terrible!
|
|
37
|
+
* That's why I have this method, just to try and create a raw request to be used and passed to the frameworks so they can handle the request
|
|
38
|
+
* as if they received the request from the native http module.
|
|
39
|
+
*
|
|
40
|
+
* @param request - The Express request
|
|
41
|
+
*/
|
|
42
|
+
getRequestFromExpressRequest(request) {
|
|
43
|
+
const expressRequestParsed = request;
|
|
44
|
+
const headers = (0, index_2.getFlattenedHeadersMap)(request.headers, ',', true);
|
|
45
|
+
const remoteAddress = headers['x-forwarded-for'];
|
|
46
|
+
let body;
|
|
47
|
+
if (expressRequestParsed.body &&
|
|
48
|
+
typeof expressRequestParsed.body === 'object') {
|
|
49
|
+
const jsonContent = JSON.stringify(expressRequestParsed.body);
|
|
50
|
+
const [bufferBody, contentLength] = (0, index_2.getEventBodyAsBuffer)(jsonContent, false);
|
|
51
|
+
body = bufferBody;
|
|
52
|
+
headers['content-length'] = String(contentLength);
|
|
53
|
+
}
|
|
54
|
+
return new index_1.ServerlessRequest({
|
|
55
|
+
method: request.method,
|
|
56
|
+
url: request.url,
|
|
57
|
+
body,
|
|
58
|
+
headers,
|
|
59
|
+
remoteAddress,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.RawRequest = RawRequest;
|
|
64
|
+
RawRequest.__type = ['TApp', 'app', () => __ΩFrameworkContract, 'framework', 'req', 'res', '', 'onRequestCallback', 'request', () => index_1.ServerlessRequest, 'getRequestFromExpressRequest', 'b!Pe"!2"e"!o#"2$P!2%!2&P$$`J/\'0(<P!2)P7*0+<5'];
|
|
65
|
+
//# sourceMappingURL=raw-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw-request.js","sourceRoot":"","sources":["../../../src/handlers/base/raw-request.ts"],"names":[],"mappings":";;;yCAGkC,uBAAuB;;;;;AACzD,+CAAwD;AACxD,4CAAgF;AAEhF,YAAY;AAEZ;;;;;GAKG;AACH,MAAsB,UAAU;IAC9B,2BAA2B;IAE3B;;;;;OAKG;IACO,iBAAiB,CACzB,GAAS,EACT,SAAkC;QAElC,oBAAO,CAAC,OAAwB,EAAE,QAAwB,EAAE,EAAE;YAC5D,MAAM,aAAa,GAAG,IAAI,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC;YAEjE,OAAO,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;QAC7D,CAAC,6CAAC;IACJ,CAAC;IAED;;;;;;;;;OASG;IACO,4BAA4B,CACpC,OAAwB;QAExB,MAAM,oBAAoB,GAAG,OAE5B,CAAC;QAEF,MAAM,OAAO,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACnE,MAAM,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAEjD,IAAI,IAAwB,CAAC;QAE7B,IACE,oBAAoB,CAAC,IAAI;YACzB,OAAO,oBAAoB,CAAC,IAAI,KAAK,QAAQ,EAC7C;YACA,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;YAE9D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,4BAAoB,EACtD,WAAW,EACX,KAAK,CACN,CAAC;YAEF,IAAI,GAAG,UAAU,CAAC;YAClB,OAAO,CAAC,gBAAgB,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;SACnD;QAED,OAAO,IAAI,yBAAiB,CAAC;YAC3B,MAAM,EAAE,OAAO,CAAC,MAAO;YACvB,GAAG,EAAE,OAAO,CAAC,GAAI;YACjB,IAAI;YACJ,OAAO;YACP,aAAa;SACd,CAAC,CAAC;IACL,CAAC;;AAhEH,gCAmEC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
import { FrameworkContract, HandlerContract } from '../../contracts';
|
|
4
|
+
import { RawRequest } from '../base/index';
|
|
4
5
|
/**
|
|
5
6
|
* The class that implements a handler for Firebase Https Events
|
|
6
7
|
*
|
|
@@ -9,7 +10,7 @@ import { FrameworkContract, HandlerContract } from '../../contracts';
|
|
|
9
10
|
* @breadcrumb Handlers / HttpFirebaseHandler
|
|
10
11
|
* @public
|
|
11
12
|
*/
|
|
12
|
-
export declare class HttpFirebaseHandler<TApp> implements HandlerContract<TApp, never, never, never, void, void | Promise<void>> {
|
|
13
|
+
export declare class HttpFirebaseHandler<TApp> extends RawRequest<TApp> implements HandlerContract<TApp, never, never, never, void, void | Promise<void>> {
|
|
13
14
|
/**
|
|
14
15
|
* {@inheritDoc}
|
|
15
16
|
*/
|
|
@@ -2,13 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpFirebaseHandler = void 0;
|
|
4
4
|
const { __ΩFrameworkContract } = require('../../contracts');
|
|
5
|
-
function __assignType(fn, args) {
|
|
6
|
-
fn.__type = args;
|
|
7
|
-
return fn;
|
|
8
|
-
}
|
|
9
5
|
const firebase_functions_1 = require("firebase-functions");
|
|
10
|
-
const
|
|
11
|
-
const network_1 = require("../../network");
|
|
6
|
+
const index_1 = require("../base/index");
|
|
12
7
|
//#endregion
|
|
13
8
|
/**
|
|
14
9
|
* The class that implements a handler for Firebase Https Events
|
|
@@ -18,35 +13,15 @@ const network_1 = require("../../network");
|
|
|
18
13
|
* @breadcrumb Handlers / HttpFirebaseHandler
|
|
19
14
|
* @public
|
|
20
15
|
*/
|
|
21
|
-
class HttpFirebaseHandler {
|
|
16
|
+
class HttpFirebaseHandler extends index_1.RawRequest {
|
|
22
17
|
//#region Public Methods
|
|
23
18
|
/**
|
|
24
19
|
* {@inheritDoc}
|
|
25
20
|
*/
|
|
26
21
|
getHandler(app, framework) {
|
|
27
|
-
return firebase_functions_1.https.onRequest(
|
|
28
|
-
const expressRequestParsed = request;
|
|
29
|
-
const headers = (0, core_1.getFlattenedHeadersMap)(request.headers, ',', true);
|
|
30
|
-
const remoteAddress = headers['x-forwarded-for'];
|
|
31
|
-
let body;
|
|
32
|
-
if (expressRequestParsed.body &&
|
|
33
|
-
typeof expressRequestParsed.body === 'object') {
|
|
34
|
-
const jsonContent = JSON.stringify(expressRequestParsed.body);
|
|
35
|
-
const [bufferBody, contentLength] = (0, core_1.getEventBodyAsBuffer)(jsonContent, false);
|
|
36
|
-
body = bufferBody;
|
|
37
|
-
headers['content-length'] = String(contentLength);
|
|
38
|
-
}
|
|
39
|
-
const customRequest = new network_1.ServerlessRequest({
|
|
40
|
-
method: request.method,
|
|
41
|
-
url: request.url,
|
|
42
|
-
body,
|
|
43
|
-
headers,
|
|
44
|
-
remoteAddress,
|
|
45
|
-
});
|
|
46
|
-
return framework.sendRequest(app, customRequest, response);
|
|
47
|
-
}, ['request', 'response', '', 'P!2!!2""/#']));
|
|
22
|
+
return firebase_functions_1.https.onRequest(this.onRequestCallback(app, framework));
|
|
48
23
|
}
|
|
49
24
|
}
|
|
50
25
|
exports.HttpFirebaseHandler = HttpFirebaseHandler;
|
|
51
|
-
HttpFirebaseHandler.__type = ['TApp', 'app', () => __ΩFrameworkContract, 'framework', 'req', 'res', '', 'getHandler', 'b!Pe"!2
|
|
26
|
+
HttpFirebaseHandler.__type = ['TApp', () => index_1.RawRequest, 'app', () => __ΩFrameworkContract, 'framework', 'req', 'res', '', 'getHandler', 'b!Pe"!7"Pe"!2#e"!o$"2%P!2&!2\'P$$`J/(0)5e!!6"'];
|
|
52
27
|
//# sourceMappingURL=http-firebase.handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-firebase.handler.js","sourceRoot":"","sources":["../../../src/handlers/firebase/http-firebase.handler.ts"],"names":[],"mappings":";;;yCAImD,iBAAiB
|
|
1
|
+
{"version":3,"file":"http-firebase.handler.js","sourceRoot":"","sources":["../../../src/handlers/firebase/http-firebase.handler.ts"],"names":[],"mappings":";;;yCAImD,iBAAiB;AADpE,2DAA2C;AAE3C,yCAA2C;AAE3C,YAAY;AACZ;;;;;;;GAOG;AACH,MAAa,mBACX,SAAQ,kBAAgB;IAIxB,wBAAwB;IAExB;;OAEG;IACI,UAAU,CACf,GAAS,EACT,SAAkC;QAElC,OAAO,0BAAK,CAAC,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;IACjE,CAAC;;AAfH,kDAkBC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
+
import { FrameworkContract, HandlerContract } from '../../contracts';
|
|
4
|
+
import { RawRequest } from '../base/index';
|
|
5
|
+
/**
|
|
6
|
+
* The class that implements a handler for GCP Http Functions
|
|
7
|
+
*
|
|
8
|
+
* @remarks Read more about Http Cloud Function {@link https://cloud.google.com/functions/docs/create-deploy-http-nodejs | here}
|
|
9
|
+
*
|
|
10
|
+
* @breadcrumb Handlers / GCPHandler
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare class GCPHandler<TApp> extends RawRequest<TApp> implements HandlerContract<TApp, never, never, never, void, void | Promise<void>> {
|
|
14
|
+
protected readonly name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Default Constructor
|
|
17
|
+
*
|
|
18
|
+
* @param name - The name of this function, should be the during deploy.
|
|
19
|
+
*/
|
|
20
|
+
constructor(name: string);
|
|
21
|
+
/**
|
|
22
|
+
* {@inheritDoc}
|
|
23
|
+
*/
|
|
24
|
+
getHandler(app: TApp, framework: FrameworkContract<TApp>): (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GCPHandler = void 0;
|
|
4
|
+
const { __ΩFrameworkContract } = require('../../contracts');
|
|
5
|
+
const functions_framework_1 = require("@google-cloud/functions-framework");
|
|
6
|
+
const index_1 = require("../base/index");
|
|
7
|
+
//#endregion
|
|
8
|
+
/**
|
|
9
|
+
* The class that implements a handler for GCP Http Functions
|
|
10
|
+
*
|
|
11
|
+
* @remarks Read more about Http Cloud Function {@link https://cloud.google.com/functions/docs/create-deploy-http-nodejs | here}
|
|
12
|
+
*
|
|
13
|
+
* @breadcrumb Handlers / GCPHandler
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
class GCPHandler extends index_1.RawRequest {
|
|
17
|
+
//#region Constructor
|
|
18
|
+
/**
|
|
19
|
+
* Default Constructor
|
|
20
|
+
*
|
|
21
|
+
* @param name - The name of this function, should be the during deploy.
|
|
22
|
+
*/
|
|
23
|
+
constructor(name) {
|
|
24
|
+
super();
|
|
25
|
+
this.name = name;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region Public Methods
|
|
29
|
+
/**
|
|
30
|
+
* {@inheritDoc}
|
|
31
|
+
*/
|
|
32
|
+
getHandler(app, framework) {
|
|
33
|
+
const callback = this.onRequestCallback(app, framework);
|
|
34
|
+
(0, functions_framework_1.http)(this.name, callback);
|
|
35
|
+
return callback;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.GCPHandler = GCPHandler;
|
|
39
|
+
GCPHandler.__type = ['TApp', () => index_1.RawRequest, 'name', 'constructor', 'app', () => __ΩFrameworkContract, 'framework', 'req', 'res', '', 'getHandler', 'b!Pe"!7"P&2#<9"0$Pe"!2%e"!o&"2\'P!2(!2)P$$`J/*0+5e!!6"'];
|
|
40
|
+
//# sourceMappingURL=gcp.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gcp.handler.js","sourceRoot":"","sources":["../../../src/handlers/gcp/gcp.handler.ts"],"names":[],"mappings":";;;yCAImD,iBAAiB;AADpE,2EAAyD;AAEzD,yCAA2C;AAE3C,YAAY;AAEZ;;;;;;;GAOG;AACH,MAAa,UACX,SAAQ,kBAAgB;IAIxB,qBAAqB;IAErB;;;;OAIG;IACH,YAA+B,IAAY;QACzC,KAAK,EAAE,CAAC;QADqB,SAAI,GAAJ,IAAI,CAAQ;IAE3C,CAAC;IAED,YAAY;IAEZ,wBAAwB;IAExB;;OAEG;IACI,UAAU,CACf,GAAS,EACT,SAAkC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAExD,IAAA,0BAAI,EAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE1B,OAAO,QAAQ,CAAC;IAClB,CAAC;;AAhCH,gCAmCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gcp.handler';
|
|
@@ -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("./gcp.handler"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/handlers/gcp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h4ad/serverless-adapter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.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, Digital Ocean and many other clouds.",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -65,7 +65,9 @@
|
|
|
65
65
|
"deepkit http",
|
|
66
66
|
"digital ocean",
|
|
67
67
|
"digital ocean functions",
|
|
68
|
-
"digital ocean serverless"
|
|
68
|
+
"digital ocean serverless",
|
|
69
|
+
"gcp",
|
|
70
|
+
"google cloud functions"
|
|
69
71
|
],
|
|
70
72
|
"bugs": {
|
|
71
73
|
"url": "https://github.com/H4ad/serverless-adapter/issues"
|
|
@@ -80,6 +82,7 @@
|
|
|
80
82
|
"@deepkit/http": ">= 1.0.1-alpha.74",
|
|
81
83
|
"@deepkit/type": ">= 1.0.1-alpha.74",
|
|
82
84
|
"@deepkit/type-compiler": ">= 1.0.1-alpha.74",
|
|
85
|
+
"@google-cloud/functions-framework": "^3.1.3",
|
|
83
86
|
"@hapi/hapi": "^20.2.2",
|
|
84
87
|
"@microsoft/api-documenter": "7.19.24",
|
|
85
88
|
"@microsoft/api-extractor": "7.33.6",
|
|
@@ -133,6 +136,7 @@
|
|
|
133
136
|
"@apollo/server": ">= 4.0.0",
|
|
134
137
|
"@azure/functions": ">= 2.0.0",
|
|
135
138
|
"@deepkit/http": ">= 1.0.1-alpha.74",
|
|
139
|
+
"@google-cloud/functions-framework": ">= 3.0.0",
|
|
136
140
|
"@hapi/hapi": ">= 20.0.0",
|
|
137
141
|
"@trpc/server": ">= 9.0.0",
|
|
138
142
|
"@types/aws-lambda": ">= 8.10.92",
|
|
@@ -163,6 +167,9 @@
|
|
|
163
167
|
"@deepkit/http": {
|
|
164
168
|
"optional": true
|
|
165
169
|
},
|
|
170
|
+
"@google-cloud/functions-framework": {
|
|
171
|
+
"optional": true
|
|
172
|
+
},
|
|
166
173
|
"@hapi/hapi": {
|
|
167
174
|
"optional": true
|
|
168
175
|
},
|