gcf-common-lib 0.39.0 → 0.40.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/package.json +1 -1
- package/src/index.ts +4 -4
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.
|
|
4
|
+
"version": "0.40.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"branches": [
|
package/src/index.ts
CHANGED
|
@@ -149,7 +149,9 @@ export const GcfCommon = {
|
|
|
149
149
|
getMetadataOrAttribute<E = TEvent>(payload: TPayload<E>) {
|
|
150
150
|
let metadataOrAttribute: TMetadataOrAttributes | undefined;
|
|
151
151
|
|
|
152
|
-
if (payload?.
|
|
152
|
+
if (payload?.request) {
|
|
153
|
+
metadataOrAttribute = GcfCommon.getRequestAttributes(payload.request);
|
|
154
|
+
} else if (payload?.context) {
|
|
153
155
|
switch (payload?.context?.eventType) {
|
|
154
156
|
case 'google.storage.object.finalize': {
|
|
155
157
|
const gsEvent = payload?.event as TGSEvent;
|
|
@@ -162,8 +164,6 @@ export const GcfCommon = {
|
|
|
162
164
|
break;
|
|
163
165
|
}
|
|
164
166
|
}
|
|
165
|
-
} else if (payload?.request) {
|
|
166
|
-
metadataOrAttribute = GcfCommon.getRequestAttributes(payload.request);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
// console.log('metadataOrAttribute:', metadataOrAttribute);
|
|
@@ -176,6 +176,6 @@ export const GcfCommon = {
|
|
|
176
176
|
},
|
|
177
177
|
|
|
178
178
|
getRequestAttributes(request: Request) {
|
|
179
|
-
return this.getRequestMessage(request)?.attributes
|
|
179
|
+
return { ...this.getRequestMessage(request)?.attributes, ...request.headers };
|
|
180
180
|
},
|
|
181
181
|
};
|