Skip to content

Commit

Permalink
Named export for poller lambda handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
bryophyta committed Dec 23, 2024
1 parent 981d7ca commit 548ac91
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cdk/lib/__snapshots__/newswires.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ exports[`The Newswires stack matches the snapshot 1`] = `
},
},
"FunctionName": "editorial-feeds-TEST-EXAMPLE_fixed_frequency_poller_lambda",
"Handler": "index.EXAMPLE_fixed_frequency",
"Handler": "index.handlers.EXAMPLE_fixed_frequency",
"LoggingConfig": {
"LogFormat": "JSON",
},
Expand Down Expand Up @@ -1260,7 +1260,7 @@ exports[`The Newswires stack matches the snapshot 1`] = `
},
},
"FunctionName": "editorial-feeds-TEST-EXAMPLE_long_polling_poller_lambda",
"Handler": "index.EXAMPLE_long_polling",
"Handler": "index.handlers.EXAMPLE_long_polling",
"LoggingConfig": {
"LogFormat": "JSON",
},
Expand Down
2 changes: 1 addition & 1 deletion cdk/lib/constructs/pollerLambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class PollerLambda {
},
memorySize: pollerConfig.overrideLambdaMemoryMB ?? 128,
timeout,
handler: `index.${pollerId}`, // see programmatically generated exports in poller-lambdas/src/index.ts
handler: `index.handlers.${pollerId}`, // see programmatically generated exports in poller-lambdas/src/index.ts
fileName: `poller-lambdas.zip`, // shared zip for all the poller-lambdas
});

Expand Down
2 changes: 1 addition & 1 deletion poller-lambdas/localRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
POLLERS_CONFIG,
} from '../shared/pollers';
import { sqs } from './src/aws';
import handlers from './src/index';
import { handlers } from './src/index';
import type { HandlerInputSqsPayload } from './src/types';

const fakeInvoke = async (
Expand Down
3 changes: 1 addition & 2 deletions poller-lambdas/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ const pollerWrapper =
}
};

// eslint-disable-next-line import/no-default-export -- we need this to expose the pollers as named handlers but the shape verified with 'satisfies' keyword
export default {
export const handlers = {
EXAMPLE_long_polling: pollerWrapper(EXAMPLE_long_polling),
EXAMPLE_fixed_frequency: pollerWrapper(EXAMPLE_fixed_frequency),
} satisfies Record<
Expand Down

0 comments on commit 548ac91

Please sign in to comment.