File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
lambdas/api-handler/src/handlers Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -2,14 +2,19 @@ import { APIGatewayProxyHandler } from "aws-lambda";
22import { getLettersForSupplier } from "../services/letter-operations" ;
33import { createLetterRepository } from "../infrastructure/letter-repo-factory" ;
44import { LetterBase } from "../../../../internal/datastore/src" ;
5+ import pino from 'pino' ;
56
67const letterRepo = createLetterRepository ( ) ;
8+ const log = pino ( ) ;
79
810export 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" ,
You can’t perform that action at this time.
0 commit comments