Skip to content

Commit

Permalink
feat: separate hard quote exports
Browse files Browse the repository at this point in the history
previously hard quote injector was built in the same index exports file
as the indicative quote injector, causing even indicative quote setup to
require a KMS_KEY_ID environment variable. This commit separates the
export into a separate file to decouple the env pulling.

Future improvement should do this same separation for rest of the
lambdas as well instead of having a global handlers/index
  • Loading branch information
marktoda committed Mar 8, 2024
1 parent 15fb966 commit 28219bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin/stacks/api-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export class APIStack extends cdk.Stack {
const hardQuoteLambda = new aws_lambda_nodejs.NodejsFunction(this, 'HardQuote', {
role: lambdaRole,
runtime: aws_lambda.Runtime.NODEJS_18_X,
entry: path.join(__dirname, '../../lib/handlers/index.ts'),
entry: path.join(__dirname, '../../lib/handlers/hard-quote/index.ts'),
handler: 'hardQuoteHandler',
vpc,
vpcSubnets: {
Expand Down
11 changes: 10 additions & 1 deletion lib/handlers/hard-quote/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
import { QuoteHandler } from './handler';
import { QuoteInjector } from './injector';
export { QuoteHandler as HardQuoteHandler } from './handler';
export { ContainerInjected, QuoteInjector as HardQuoteInjector, RequestInjected } from './injector';
export { RequestInjected, ContainerInjected, QuoteInjector as HardQuoteInjector } from './injector';
export * from './schema';

const hardQuoteInjectorPromise = new QuoteInjector('hardQuoteInjector').build();
const hardQuoteHandler = new QuoteHandler('hardQuoteHandler', hardQuoteInjectorPromise);

module.exports = {
hardQuoteHandler: hardQuoteHandler.handler,
};
5 changes: 0 additions & 5 deletions lib/handlers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@ import {
postOrderProcessor,
quoteProcessor,
} from './blueprints/cw-log-firehose-processor';
import { HardQuoteHandler, HardQuoteInjector } from './hard-quote';
import { RfqHandler, RfqInjector } from './integration/rfq';
import { MockQuoteInjector, QuoteHandler, QuoteInjector } from './quote';
import { SwitchHandler, SwitchInjector } from './synth-switch';

const quoteInjectorPromise = new QuoteInjector('quoteInjector').build();
const quoteHandler = new QuoteHandler('quoteHandler', quoteInjectorPromise);

const hardQuoteInjectorPromise = new HardQuoteInjector('hardQuoteInjector').build();
const hardQuoteHandler = new HardQuoteHandler('hardQuoteHandler', hardQuoteInjectorPromise);

const switchInjectorPromise = new SwitchInjector('switchInjector').build();
const switchHandler = new SwitchHandler('SwitchHandler', switchInjectorPromise);

Expand All @@ -30,7 +26,6 @@ module.exports = {
quoteProcessor: quoteProcessor,
botOrderEventsProcessor: botOrderEventsProcessor,
quoteHandler: quoteHandler.handler,
hardQuoteHandler: hardQuoteHandler.handler,
mockQuoteHandler: mockQuoteHandler.handler,
rfqHandler: rfqHandler.handler,
switchHandler: switchHandler.handler,
Expand Down

0 comments on commit 28219bc

Please sign in to comment.