@h4ad/serverless-adapter 2.13.0 → 2.13.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.
@@ -7,6 +7,8 @@ function __assignType(fn, args) {
7
7
  return fn;
8
8
  }
9
9
  const firebase_functions_1 = require("firebase-functions");
10
+ const core_1 = require("../../core");
11
+ const network_1 = require("../../network");
10
12
  //#endregion
11
13
  /**
12
14
  * The class that implements a handler for Firebase Https Events
@@ -23,12 +25,25 @@ class HttpFirebaseHandler {
23
25
  */
24
26
  getHandler(app, framework) {
25
27
  return firebase_functions_1.https.onRequest(__assignType((request, response) => {
26
- const serverlessRequest = request;
27
- if (serverlessRequest.body &&
28
- typeof serverlessRequest.body === 'object') {
29
- serverlessRequest.body = Buffer.from(JSON.stringify(serverlessRequest.body), 'utf-8');
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);
30
38
  }
31
- return framework.sendRequest(app, serverlessRequest, response);
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);
32
47
  }, ['request', 'response', '', 'P!2!!2""/#']));
33
48
  }
34
49
  }
@@ -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;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"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h4ad/serverless-adapter",
3
- "version": "2.13.0",
3
+ "version": "2.13.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": [