Skip to content

Commit

Permalink
feat(CB2-14229): pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-Searle committed Oct 22, 2024
1 parent 12cc5e6 commit 131d759
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/functions/reportGen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LambdaClient } from "@aws-sdk/client-lambda";
import { unmarshall } from "@aws-sdk/util-dynamodb";
import { Callback, Context, Handler, SQSBatchItemFailure, SQSBatchResponse } from "aws-lambda";
import { Callback, Context, Handler, SQSBatchItemFailure, SQSBatchResponse, SQSEvent } from "aws-lambda";
import { ERRORS } from "../assets/enum";
import { ActivitiesService } from "../services/ActivitiesService";
import { LambdaService } from "../services/LambdaService";
Expand All @@ -15,7 +15,7 @@ import { ActivitySchema } from "@dvsa/cvs-type-definitions/types/v1/activity";
* @param context - λ Context
* @param callback - callback function
*/
const reportGen: Handler = async (event: any, context?: Context, callback?: Callback): Promise<SQSBatchResponse> => {
const reportGen: Handler = async (event: SQSEvent, context?: Context, callback?: Callback): Promise<SQSBatchResponse> => {
if (!event || !event.Records || !Array.isArray(event.Records) || !event.Records.length) {
console.error("ERROR: event is not defined.");
throw new Error(ERRORS.EVENT_IS_EMPTY);
Expand All @@ -38,14 +38,11 @@ const reportGen: Handler = async (event: any, context?: Context, callback?: Call
const generationServiceResponse = await reportService.generateATFReport(visit);
console.debug(`Report generated: ${JSON.stringify(generationServiceResponse)}`);
await sendATFReport.sendATFReport(generationServiceResponse, visit);
console.debug("All emails sent, terminating lambda");
}

} catch (error) {
console.error(error);
batchItemFailures.push({
itemIdentifier: record.messageId,
});
batchItemFailures.push({ itemIdentifier: record.messageId });
}
}
return { batchItemFailures };
Expand Down

0 comments on commit 131d759

Please sign in to comment.