Skip to content

Commit 78671d2

Browse files
committed
CCM-11602: Add logging
1 parent 19c2838 commit 78671d2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@ import { APIGatewayProxyHandler } from "aws-lambda";
22
import { getLettersForSupplier } from "../services/letter-operations";
33
import { createLetterRepository } from "../infrastructure/letter-repo-factory";
44
import { LetterBase } from "../../../../internal/datastore/src";
5+
import pino from 'pino';
56

67
const letterRepo = createLetterRepository();
8+
const log = pino();
79

810
export const getLetters: APIGatewayProxyHandler = async (event) => {
911
if (event.path === "/letters") {
1012
const supplierId = event.headers ? event.headers["NHSD-Supplier-ID"] : undefined;
1113

1214
if (!supplierId) {
15+
log.info({
16+
description: 'Supplier ID not provided'
17+
});
1318
return {
1419
statusCode: 400,
1520
body: "Bad Request: Missing supplier ID",
@@ -34,12 +39,25 @@ export const getLetters: APIGatewayProxyHandler = async (event) => {
3439

3540
const response = createGetLettersResponse(letters);
3641

42+
log.info({
43+
description: 'Pending letters successfully fetched',
44+
supplierId,
45+
size,
46+
status,
47+
lettersCount: letters.length
48+
});
49+
3750
return {
3851
statusCode: 200,
3952
body: JSON.stringify(response, null, 2),
4053
};
4154
}
4255

56+
log.warn({
57+
description: 'Unsupported event path',
58+
path: event.path
59+
});
60+
4361
return {
4462
statusCode: 404,
4563
body: "Not Found",

0 commit comments

Comments
 (0)