gcf-common-lib 0.36.0 → 0.39.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.
Files changed (2) hide show
  1. package/package.json +3 -5
  2. package/src/index.ts +5 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gcf-common-lib",
3
3
  "description": "Common helpers for Google Cloud Functions: Pub/Sub publishing, Mongo helpers, and utilities for Node 20+ (TypeScript).",
4
- "version": "0.36.0",
4
+ "version": "0.39.0",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "branches": [
@@ -14,9 +14,7 @@
14
14
  "main": "src/index",
15
15
  "scripts": {
16
16
  "build": "tsc",
17
- "test": "node --test .\\test\\sample.test.js",
18
- "test:ts": "node --test --import tsx .\\test",
19
- "test:coverage": "c8 --reporter=text --reporter=html node --test .\\test\\sample.test.js"
17
+ "test": "node --test ./test/"
20
18
  },
21
19
  "repository": {
22
20
  "type": "git",
@@ -35,7 +33,7 @@
35
33
  "@google-cloud/pubsub": "^5.2.0",
36
34
  "@google-cloud/storage": "^7.18.0",
37
35
  "@types/bluebird": "^3.5.42",
38
- "@types/express": "^4.17.25",
36
+ "@types/express": "^5.0.6",
39
37
  "@types/lodash": "^4.17.21",
40
38
  "bluebird": "^3.7.2",
41
39
  "lodash": "^4.17.21",
package/src/index.ts CHANGED
@@ -163,7 +163,7 @@ export const GcfCommon = {
163
163
  }
164
164
  }
165
165
  } else if (payload?.request) {
166
- metadataOrAttribute = GcfCommon.getRequestMessage(payload.request)?.attributes;
166
+ metadataOrAttribute = GcfCommon.getRequestAttributes(payload.request);
167
167
  }
168
168
 
169
169
  // console.log('metadataOrAttribute:', metadataOrAttribute);
@@ -174,4 +174,8 @@ export const GcfCommon = {
174
174
  getRequestMessage(request: Request) {
175
175
  return request.body.message as { attributes: TMetadataOrAttributes; data: string; json?: Dict<any> };
176
176
  },
177
+
178
+ getRequestAttributes(request: Request) {
179
+ return this.getRequestMessage(request)?.attributes ?? request.headers;
180
+ },
177
181
  };