Skip to content

Commit 16f802c

Browse files
committed
Address review comments
1 parent 77c3202 commit 16f802c

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

infrastructure/terraform/components/api/locals.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ locals {
55
root_domain_nameservers = local.acct.route53_zone_nameservers["supplier-api"]
66

77
openapi_spec = templatefile("${path.module}/resources/spec.tmpl.json", {
8-
APIG_EXECUTION_ROLE_ARN = aws_iam_role.api_gateway_execution_role.arn
9-
AWS_REGION = var.region
10-
AUTHORIZER_LAMBDA_ARN = module.authorizer_lambda.function_arn
11-
GET_LETTER_LAMBDA_ARN = module.get_letter.function_arn
12-
GET_LETTERS_LAMBDA_ARN = module.get_letters.function_arn
8+
APIG_EXECUTION_ROLE_ARN = aws_iam_role.api_gateway_execution_role.arn
9+
AWS_REGION = var.region
10+
AUTHORIZER_LAMBDA_ARN = module.authorizer_lambda.function_arn
11+
GET_LETTER_LAMBDA_ARN = module.get_letter.function_arn
12+
GET_LETTERS_LAMBDA_ARN = module.get_letters.function_arn
1313
GET_LETTER_DATA_LAMBDA_ARN = module.get_letter_data.function_arn
14-
PATCH_LETTER_LAMBDA_ARN = module.patch_letter.function_arn
15-
GET_STATUS_LAMBDA_ARN = module.get_status.function_arn
14+
GET_STATUS_LAMBDA_ARN = module.get_status.function_arn
15+
PATCH_LETTER_LAMBDA_ARN = module.patch_letter.function_arn
1616
})
1717

1818
destination_arn = "arn:aws:logs:${var.region}:${var.shared_infra_account_id}:destination:nhs-main-obs-firehose-logs"

infrastructure/terraform/components/api/module_lambda_get_status.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ module "get_status" {
3434
send_to_firehose = true
3535
log_destination_arn = local.destination_arn
3636
log_subscription_role_arn = local.acct.log_subscription_role_arn
37-
38-
lambda_env_vars = merge(local.common_lambda_env_vars, {
39-
MAX_LIMIT = var.max_get_limit
40-
})
4137
}
4238

4339
data "aws_iam_policy_document" "get_status_lambda" {

lambdas/api-handler/src/config/deps.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,39 @@ export type Deps = {
1313
env: EnvVars
1414
};
1515

16-
function createLetterRepository(log: pino.Logger, envVars: EnvVars): LetterRepository {
16+
function createDocumentClient(): DynamoDBDocumentClient {
1717
const ddbClient = new DynamoDBClient({});
18-
const docClient = DynamoDBDocumentClient.from(ddbClient);
18+
return DynamoDBDocumentClient.from(ddbClient);
19+
}
20+
21+
22+
function createLetterRepository(documentClient: DynamoDBDocumentClient, log: pino.Logger, envVars: EnvVars): LetterRepository {
1923
const config = {
2024
lettersTableName: envVars.LETTERS_TABLE_NAME,
2125
ttlHours: envVars.LETTER_TTL_HOURS
2226
};
2327

24-
return new LetterRepository(docClient, log, config);
28+
return new LetterRepository(documentClient, log, config);
2529
}
2630

27-
function createDBHealthcheck(envVars: EnvVars): DBHealthcheck {
28-
const ddbClient = new DynamoDBClient({});
29-
const docClient = DynamoDBDocumentClient.from(ddbClient);
31+
function createDBHealthcheck(documentClient: DynamoDBDocumentClient, envVars: EnvVars): DBHealthcheck {
3032
const config = {
3133
lettersTableName: envVars.LETTERS_TABLE_NAME,
3234
ttlHours: envVars.LETTER_TTL_HOURS
3335
};
3436

35-
return new DBHealthcheck(docClient, config);
37+
return new DBHealthcheck(documentClient, config);
3638
}
3739

3840
export function createDependenciesContainer(): Deps {
3941

4042
const log = pino();
43+
const documentClient = createDocumentClient();
4144

4245
return {
4346
s3Client: new S3Client(),
44-
letterRepo: createLetterRepository(log, envVars),
45-
dbHealthcheck: createDBHealthcheck(envVars),
47+
letterRepo: createLetterRepository(documentClient, log, envVars),
48+
dbHealthcheck: createDBHealthcheck(documentClient, envVars),
4649
logger: log,
4750
env: envVars
4851
};

lambdas/api-handler/src/handlers/__tests__/get_status.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('API Lambda handler', () => {
1919

2020
expect(result).toEqual({
2121
statusCode: 200,
22-
body: JSON.stringify({}, null, 2),
22+
body: '{}',
2323
});
2424
});
2525

lambdas/api-handler/src/handlers/get-status.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ export function createGetStatusHandler(deps: Deps): APIGatewayProxyHandler {
2525

2626
return {
2727
statusCode: 200,
28-
body: JSON.stringify({}, null, 2)
28+
body: '{}'
2929
};
3030
} catch (error) {
3131
return mapErrorToResponse(error, commonHeadersResult.value.correlationId, deps.logger);
32-
}
32+
}
3333
}
3434
}
3535

0 commit comments

Comments
 (0)