gcf-common-lib 0.28.61 → 0.28.62
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.js +10 -1
- package/src/index.ts +10 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -59,7 +59,16 @@ class GcfCommon {
|
|
|
59
59
|
*/
|
|
60
60
|
static async process(event, context, handler = rxjs_1.identity, timeoutSec = 535) {
|
|
61
61
|
const asyncHandler = async (_event, _context) => await handler(_event, _context);
|
|
62
|
-
return (0, rxjs_1.firstValueFrom)((0, rxjs_1.defer)(() => (0, rxjs_1.from)(asyncHandler(event, context))).pipe((0, rxjs_1.first)(), (0, rxjs_1.timeout)({ first: (0, utils_1.ms)({ s: timeoutSec }) })))
|
|
62
|
+
return (0, rxjs_1.firstValueFrom)((0, rxjs_1.defer)(() => (0, rxjs_1.from)(asyncHandler(event, context))).pipe((0, rxjs_1.first)(), (0, rxjs_1.timeout)({ first: (0, utils_1.ms)({ s: timeoutSec }) })))
|
|
63
|
+
.then(async (res) => {
|
|
64
|
+
// console.log('res:', res);
|
|
65
|
+
await this.publish(event, context, res).catch(noop_1.default);
|
|
66
|
+
return res;
|
|
67
|
+
})
|
|
68
|
+
.catch(async (error) => {
|
|
69
|
+
await this.publish(event, context, GcfCommon.buildResponse(error), { error: '1' }).catch(noop_1.default);
|
|
70
|
+
throw error;
|
|
71
|
+
});
|
|
63
72
|
}
|
|
64
73
|
static async processOLd(event, context, handler = rxjs_1.identity, timeoutSec = 535) {
|
|
65
74
|
return Promise.race([(0, utils_1.timeoutAfter)(timeoutSec), handler(event, context)])
|
package/src/index.ts
CHANGED
|
@@ -52,7 +52,16 @@ export class GcfCommon {
|
|
|
52
52
|
const asyncHandler = async (_event: any, _context: any) => await handler(_event, _context);
|
|
53
53
|
return firstValueFrom(
|
|
54
54
|
defer(() => from(asyncHandler(event, context))).pipe(first(), timeout({ first: ms({ s: timeoutSec }) })),
|
|
55
|
-
)
|
|
55
|
+
)
|
|
56
|
+
.then(async res => {
|
|
57
|
+
// console.log('res:', res);
|
|
58
|
+
await this.publish(event, context, res as T).catch(noop);
|
|
59
|
+
return res;
|
|
60
|
+
})
|
|
61
|
+
.catch(async (error: Error) => {
|
|
62
|
+
await this.publish(event, context, GcfCommon.buildResponse(error), { error: '1' }).catch(noop);
|
|
63
|
+
throw error;
|
|
64
|
+
});
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
static async processOLd<T extends TResponse, E = TEvent>(
|