From 798460fe84a4adfffe29b99fd2729a11eb91adf5 Mon Sep 17 00:00:00 2001 From: Arno Gau Date: Tue, 14 Nov 2023 03:16:08 +0200 Subject: [PATCH 1/2] Add _events and cb to the callback function in EventHandler Add _events and cb to the callback function in EventHandler to make reflection easier. --- packages/sst/src/node/event-bus/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/sst/src/node/event-bus/index.ts b/packages/sst/src/node/event-bus/index.ts index 11ccd82200..a836a3b6f9 100644 --- a/packages/sst/src/node/event-bus/index.ts +++ b/packages/sst/src/node/event-bus/index.ts @@ -146,7 +146,7 @@ export function EventHandler( }[Events["type"]] ) => Promise ) { - return async ( + const fn = async ( event: EventBridgeEvent & { attempts?: number } ) => { await cb({ @@ -156,4 +156,7 @@ export function EventHandler( attempts: event.attempts ?? 0, }); }; + fn._events = _events; + fn.cb = cb; + return fn; } From 7bcd3d7f732564543574eaa8503414d7ad883cee Mon Sep 17 00:00:00 2001 From: Arno Gau Date: Tue, 14 Nov 2023 03:26:26 +0200 Subject: [PATCH 2/2] Update index.ts --- packages/sst/src/node/event-bus/index.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/sst/src/node/event-bus/index.ts b/packages/sst/src/node/event-bus/index.ts index a836a3b6f9..ea25e430ec 100644 --- a/packages/sst/src/node/event-bus/index.ts +++ b/packages/sst/src/node/event-bus/index.ts @@ -156,7 +156,5 @@ export function EventHandler( attempts: event.attempts ?? 0, }); }; - fn._events = _events; - fn.cb = cb; - return fn; + return Object.assign(fn, { _events, cb }); }