@@ -17,14 +17,14 @@ const flattenObjects = [(acc, el) => ({ ...acc, ...el }), {}];
1717const setupRoutesV2 = ( config , service ) =>
1818 Array . isArray ( service . routes )
1919 ? {
20- [ service . basePath ] : onRequest (
21- {
22- region : config . region ,
23- ...( config . runtimeOptions || service . runtimeOptions ) ,
24- } ,
25- parseRoutes ( config , service )
26- ) ,
27- }
20+ [ service . basePath ] : onRequest (
21+ {
22+ region : config . region ,
23+ ...( config . runtimeOptions || service . runtimeOptions ) ,
24+ } ,
25+ parseRoutes ( config , service )
26+ ) ,
27+ }
2828 : { } ;
2929
3030const setupOnCreateV2 = ( config , service ) =>
@@ -57,85 +57,84 @@ const setupOnDeleteV2 = (config, service) =>
5757const setupDBTriggersV2 = ( config , service ) =>
5858 service . publishChanges
5959 ? {
60- [ `${ service . basePath } _onCreate` ] : setupOnCreateV2 ( config , service ) ,
61- [ `${ service . basePath } _onUpdate` ] : setupOnUpdateV2 ( config , service ) ,
62- [ `${ service . basePath } _onDelete` ] : setupOnDeleteV2 ( config , service ) ,
63- }
60+ [ `${ service . basePath } _onCreate` ] : setupOnCreateV2 ( config , service ) ,
61+ [ `${ service . basePath } _onUpdate` ] : setupOnUpdateV2 ( config , service ) ,
62+ [ `${ service . basePath } _onDelete` ] : setupOnDeleteV2 ( config , service ) ,
63+ }
6464 : { } ;
6565
6666const setupKeepAliveV2 = ( config , service ) =>
6767 service . keepAlive
6868 ? {
69- [ `${ service . basePath } _keep_alive` ] : onSchedule (
70- { region : config . region , schedule : "every 5 minutes" } ,
71- keepFunctionAlive ( service )
72- ) ,
73- }
69+ [ `${ service . basePath } _keep_alive` ] : onSchedule (
70+ { region : config . region , schedule : "every 5 minutes" } ,
71+ keepFunctionAlive ( service )
72+ ) ,
73+ }
7474 : { } ;
7575
7676const setupScheduleV2 =
7777 ( config , service ) =>
78- ( {
79- time,
80- name,
81- function : toExecute ,
82- timeZone = "America/New_York" ,
83- runtimeOptions,
84- } ) =>
85- [
86- [ `${ service . basePath } _${ name } ` ] ,
87- onSchedule (
88- {
89- schedule : time ,
90- region : config . region ,
91- timeZone,
92- ...( runtimeOptions || service . runtimeOptions ) ,
93- } ,
94- toExecute
95- ) ,
96- ] ;
78+ ( {
79+ time,
80+ name,
81+ function : toExecute ,
82+ timeZone = "America/New_York" ,
83+ runtimeOptions,
84+ } ) =>
85+ [
86+ [ `${ service . basePath } _${ name } ` ] ,
87+ onSchedule (
88+ {
89+ schedule : time ,
90+ region : config . region ,
91+ timeZone,
92+ ...( runtimeOptions || service . runtimeOptions ) ,
93+ } ,
94+ toExecute
95+ ) ,
96+ ] ;
9797
9898const setupSchedulesV2 = ( config , service ) =>
9999 Array . isArray ( service . schedule )
100100 ? service . schedule
101- . map ( setupScheduleV2 ( config , service ) )
102- . reduce ( ...fromEntries )
101+ . map ( setupScheduleV2 ( config , service ) )
102+ . reduce ( ...fromEntries )
103103 : { } ;
104104
105105const setupEventV2 =
106106 ( config , service ) =>
107- ( {
108- topic,
109- type = "" ,
110- function : toExecute ,
111- ensureIdempotent = false ,
112- maxAge,
113- runtimeOptions,
114- } ) => {
115- const functionName = `${ service . basePath } _${ topic } ${
116- type ? `_${ type } ` : ""
117- } `;
118-
119- const handlerWithIdempotency = ensureIdempotent
120- ? withIdempotencyV2 ( functionName , toExecute )
121- : toExecute ;
122-
123- const handler = maxAge
124- ? ignoreOldEventsV2 ( maxAge , handlerWithIdempotency )
125- : handlerWithIdempotency ;
126-
127- return [
128- functionName ,
129- onMessagePublished (
130- {
131- topic,
132- region : config . region ,
133- ...( runtimeOptions || service . runtimeOptions ) ,
134- } ,
135- parseMessageV2 ( handler )
136- ) ,
137- ] ;
138- } ;
107+ ( {
108+ topic,
109+ type = "" ,
110+ function : toExecute ,
111+ ensureIdempotent = false ,
112+ maxAge,
113+ runtimeOptions,
114+ } ) => {
115+ const functionName = `${ service . basePath } _${ topic } ${ type ? `_${ type } ` : ""
116+ } `;
117+
118+ const handlerWithIdempotency = ensureIdempotent
119+ ? withIdempotencyV2 ( functionName , toExecute )
120+ : toExecute ;
121+
122+ const handler = maxAge
123+ ? ignoreOldEventsV2 ( maxAge , handlerWithIdempotency )
124+ : handlerWithIdempotency ;
125+
126+ return [
127+ functionName ,
128+ onMessagePublished (
129+ {
130+ topic,
131+ region : config . region ,
132+ ...( runtimeOptions || service . runtimeOptions ) ,
133+ } ,
134+ parseMessageV2 ( handler )
135+ ) ,
136+ ] ;
137+ } ;
139138
140139const setupEventsV2 = ( config , service ) =>
141140 Array . isArray ( service . events )
0 commit comments