@h4ad/serverless-adapter 2.14.1 → 2.15.1

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/README.md CHANGED
@@ -7,6 +7,7 @@
7
7
  <a href="#usage">Usage</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
8
8
  <a href="#support">Support</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
9
9
  <a href="#examples">Examples</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
10
+ <a href="#benchmark">Benchmark</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
10
11
  <a href="#architecture">Architecture</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
11
12
  <a href="#credits">Credits</a>
12
13
  </p>
@@ -89,6 +90,10 @@ See how to use this library [here](https://viniciusl.com.br/serverless-adapter/d
89
90
 
90
91
  You can see some examples of how to use this library [here](https://github.com/H4ad/serverless-adapter-examples).
91
92
 
93
+ # Benchmark
94
+
95
+ See the speed comparison between other libraries that have the same purpose in the [Benchmark Section](./benchmark).
96
+
92
97
  # Credits
93
98
 
94
99
  Honestly, I just refactored all the code that the @vendia team and many other contributors wrote, thanks so much to them
@@ -22,6 +22,33 @@ exports.__ΩILogger = __ΩILogger;
22
22
  * @public
23
23
  */
24
24
  const InternalLoggerSymbol = Symbol('InternalLogger');
25
+ const errorLogLevel = new Map([
26
+ ['debug', true],
27
+ ['verbose', true],
28
+ ['info', true],
29
+ ['warn', true],
30
+ ['error', true],
31
+ ]);
32
+ const warnLogLevel = new Map([
33
+ ['debug', true],
34
+ ['verbose', true],
35
+ ['info', true],
36
+ ['warn', true],
37
+ ]);
38
+ const infoLogLevel = new Map([
39
+ ['debug', true],
40
+ ['verbose', true],
41
+ ['info', true],
42
+ ]);
43
+ const verboseLogLevel = new Map([
44
+ ['debug', true],
45
+ ['verbose', true],
46
+ ]);
47
+ const lazyPrint = __assignType(value => {
48
+ if (typeof value === 'function')
49
+ return value();
50
+ return value;
51
+ }, ['value', '', 'P"2!"/"']);
25
52
  /**
26
53
  * The method used to create a simple logger instance to use in this library.
27
54
  *
@@ -41,36 +68,32 @@ const InternalLoggerSymbol = Symbol('InternalLogger');
41
68
  * @public
42
69
  */
43
70
  function createDefaultLogger({ level } = { level: 'error' }) {
44
- const errorLogLevel = ['debug', 'verbose', 'info', 'warn', 'error'];
45
- const warnLogLevel = ['debug', 'verbose', 'info', 'warn'];
46
- const infoLogLevel = ['debug', 'verbose', 'info'];
47
- const verboseLogLevel = ['debug', 'verbose'];
48
71
  return {
49
72
  [InternalLoggerSymbol]: true,
50
73
  error: __assignType((message, ...additional) => {
51
- if (!errorLogLevel.includes(level))
74
+ if (!errorLogLevel.has(level))
52
75
  return;
53
- console.error(message, ...additional);
76
+ console.error(message, ...additional.map(lazyPrint));
54
77
  }, ['message', 'additional', '', 'P"2!"@2""/#']),
55
78
  warn: __assignType((message, ...additional) => {
56
- if (!warnLogLevel.includes(level))
79
+ if (!warnLogLevel.has(level))
57
80
  return;
58
- console.warn(message, ...additional);
81
+ console.warn(message, ...additional.map(lazyPrint));
59
82
  }, ['message', 'additional', '', 'P"2!"@2""/#']),
60
83
  info: __assignType((message, ...additional) => {
61
- if (!infoLogLevel.includes(level))
84
+ if (!infoLogLevel.has(level))
62
85
  return;
63
- console.info(message, ...additional);
86
+ console.info(message, ...additional.map(lazyPrint));
64
87
  }, ['message', 'additional', '', 'P"2!"@2""/#']),
65
88
  verbose: __assignType((message, ...additional) => {
66
- if (!verboseLogLevel.includes(level))
89
+ if (!verboseLogLevel.has(level))
67
90
  return;
68
- console.debug(message, ...additional);
91
+ console.debug(message, ...additional.map(lazyPrint));
69
92
  }, ['message', 'additional', '', 'P"2!"@2""/#']),
70
93
  debug: __assignType((message, ...additional) => {
71
94
  if (level !== 'debug')
72
95
  return;
73
- console.debug(message, ...additional);
96
+ console.debug(message, ...additional.map(lazyPrint));
74
97
  }, ['message', 'additional', '', 'P"2!"@2""/#']),
75
98
  };
76
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA6CA;;;;;GAKG;AACH,MAAM,oBAAoB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEtD;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,mBAAmB,CACjC,EAAE,KAAK,KAAoB,EAAE,KAAK,EAAE,OAAO,EAAE;IAE7C,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACpE,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1D,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAClD,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAE7C,OAAO;QACL,CAAC,oBAAoB,CAAC,EAAE,IAAI;QAC5B,KAAK,eAAE,CAAC,OAAO,EAAE,GAAG,UAAU,EAAE,EAAE;YAChC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,OAAO;YAE3C,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC;QACxC,CAAC,+CAAA;QACD,IAAI,eAAE,CAAC,OAAO,EAAE,GAAG,UAAU,EAAE,EAAE;YAC/B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,OAAO;YAE1C,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC;QACvC,CAAC,+CAAA;QACD,IAAI,eAAE,CAAC,OAAO,EAAE,GAAG,UAAU,EAAE,EAAE;YAC/B,IAAI,CAAC,YAAY,CAAC,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E;YAC/B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,OAAO;YAErC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;QACtD,CAAC,+CAAA;QACD,OAAO,eAAE,CAAC,OAAO,EAAE,GAAG,UAAU,EAAE,EAAE;YAClC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,OAAO;YAExC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;QACvD,CAAC,+CAAA;QACD,KAAK,eAAE,CAAC,OAAO,EAAE,GAAG,UAAU,EAAE,EAAE;YAChC,IAAI,KAAK,KAAK,OAAO;gBAAE,OAAO;YAE9B,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;QACvD,CAAC,+CAAA;KACS,CAAC;AACf,CAAC;AA/BD,kDA+BC;;AAED;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAAC,MAAe;IAC9C,OAAO,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACxC,CAAC;AAFD,4CAEC"}
@@ -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"}
@@ -61,12 +61,12 @@ class DefaultHandler extends core_1.BaseHandler {
61
61
  * @param respondWithErrors - Indicates whether the error stack should be included in the response or not
62
62
  */
63
63
  onReceiveRequest(log, event, context, binarySettings, respondWithErrors) {
64
- log.debug('SERVERLESS_ADAPTER:PROXY', {
64
+ log.debug('SERVERLESS_ADAPTER:PROXY', () => ({
65
65
  event: util_1.default.inspect(event, { depth: null }),
66
66
  context: util_1.default.inspect(context, { depth: null }),
67
67
  binarySettings,
68
68
  respondWithErrors,
69
- });
69
+ }));
70
70
  }
71
71
  /**
72
72
  * The hook executed after resolve the adapter that will be used to handle the request and response
@@ -129,10 +129,10 @@ class DefaultHandler extends core_1.BaseHandler {
129
129
  * @param body - The body of the response sent by the framework
130
130
  */
131
131
  onForwardResponseAdapterResponse(log, successResponse, body) {
132
- log.debug('SERVERLESS_ADAPTER:FORWARD_RESPONSE:EVENT_SOURCE_RESPONSE', {
132
+ log.debug('SERVERLESS_ADAPTER:FORWARD_RESPONSE:EVENT_SOURCE_RESPONSE', () => ({
133
133
  successResponse: util_1.default.inspect(successResponse, { depth: null }),
134
134
  body,
135
- });
135
+ }));
136
136
  }
137
137
  //#endregion
138
138
  //#region Protected Methods
@@ -1 +1 @@
1
- {"version":3,"file":"default.handler.js","sourceRoot":"","sources":["../../../src/handlers/default/default.handler.ts"],"names":[],"mappings":";;;;;;yCAUO,iBAAiB;uCAAjB,iBAAiB;wCAAjB,iBAAiB;sCAP2B,cAAc;+BAc1D,YAAY;yCAPZ,iBAAiB;sCAAjB,iBAAiB;0CAP2B,cAAc;;;;;AAHjE,iBAAiB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CAAC,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QAE3E,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;YAC1C,KAAK;YACL,UAAU;YACV,IAAI;YACJ,OAAO;YACP,eAAe;YACf,QAAQ;YACR,GAAG;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,gCAAgC,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QAErE,OAAO,eAAe,CAAC;IACzB,CAAC;;AApRH,wCAuRC"}
1
+ {"version":3,"file":"default.handler.js","sourceRoot":"","sources":["../../../src/handlers/default/default.handler.ts"],"names":[],"mappings":";;;;;;yCAUO,iBAAiB;uCAAjB,iBAAiB;wCAAjB,iBAAiB;sCAP2B,cAAc;+BAc1D,YAAY;yCAPZ,iBAAiB;sCAAjB,iBAAiB;0CAP2B,cAAc;;;;;AAHjE,iBAAiB;AAEjB,gDAAwB;AASxB,qCAMoB;AACpB,2CAAmD;AAEnD,YAAY;AAEZ;;;;;GAKG;AACH,MAAa,cAOX,SAAQ,kBAAkE;IAC1E,wBAAwB;IAExB;;OAEG;IACI,UAAU,CACf,GAAS,EACT,SAAkC,EAClC,QAAwD,EACxD,eAMC,EACD,cAA8B,EAC9B,iBAA0B,EAC1B,GAAY;QAEZ,oBAAO,CAAC,KAAa,EAAE,OAAiB,EAAE,QAAoB,EAAE,EAAE;YAChE,IAAI,CAAC,gBAAgB,CACnB,GAAG,EACH,KAAK,EACL,OAAO,EACP,cAAc,EACd,iBAAiB,CAClB,CAAC;YAEF,MAAM,OAAO,GAAG,IAAI,CAAC,2BAA2B,CAC9C,KAAK,EACL,OAAO,EACP,QAAQ,EACR,GAAG,CACJ,CAAC;YAEF,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAEpC,IAAA,uBAAgB,EAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;YAEr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EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;;;OAQG;IACO,eAAe,CACvB,KAAa,EACb,QAA4B,EAC5B,OAAqD,EACrD,cAA8B,EAC9B,GAAY;QAEZ,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QACvC,MAAM,OAAO,GAAG,4BAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACrD,MAAM,eAAe,GAAG,IAAA,eAAQ,EAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC1D,MAAM,QAAQ,GAAG,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;QACrD,MAAM,IAAI,GAAG,4BAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAClE,MAAM,OAAO,GAAG,eAAe,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC;QAE5D,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QAE3E,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;YAC1C,KAAK;YACL,UAAU;YACV,IAAI;YACJ,OAAO;YACP,eAAe;YACf,QAAQ;YACR,GAAG;SACJ,CAAC,CAAC;QAEH,IAAI,CAAC,gCAAgC,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QAErE,OAAO,eAAe,CAAC;IACzB,CAAC;;AAvRH,wCA0RC"}
@@ -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 core_1 = require("../../core");
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(__assignType((request, response) => {
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"e"!o#"2$P!2%!2&P$$`J/\'0(5e!!!!!$P$$`J6\''];
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;;;;;AADpE,2DAA2C;AAE3C,qCAA0E;AAC1E,2CAAkD;AAElD,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,oBAAoB,GAAG,OAE5B,CAAC;YAEF,MAAM,OAAO,GAAG,IAAA,6BAAsB,EAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YACnE,MAAM,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;YAEjD,IAAI,IAAwB,CAAC;YAE7B,IACE,oBAAoB,CAAC,IAAI;gBACzB,OAAO,oBAAoB,CAAC,IAAI,KAAK,QAAQ,EAC7C;gBACA,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;gBAE9D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,2BAAoB,EACtD,WAAW,EACX,KAAK,CACN,CAAC;gBAEF,IAAI,GAAG,UAAU,CAAC;gBAClB,OAAO,CAAC,gBAAgB,CAAC,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;aACnD;YAED,MAAM,aAAa,GAAG,IAAI,2BAAiB,CAAC;gBAC1C,MAAM,EAAE,OAAO,CAAC,MAAO;gBACvB,GAAG,EAAE,OAAO,CAAC,GAAI;gBACjB,IAAI;gBACJ,OAAO;gBACP,aAAa;aACd,CAAC,CAAC;YAEH,OAAO,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC;QAC7D,CAAC,6CACF,CAAC;IACJ,CAAC;;AAlDH,kDAqDC"}
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.14.1",
3
+ "version": "2.15.1",
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
  },