Skip to content

Commit a38c8f8

Browse files
Fix spec and return code
1 parent 40f7580 commit a38c8f8

File tree

3 files changed

+47
-31
lines changed

3 files changed

+47
-31
lines changed

infrastructure/terraform/components/api/resources/spec.tmpl.json

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,34 +54,6 @@
5454
}
5555
},
5656
"/letters/{id}": {
57-
"get": {
58-
"description": "Returns 302 with pre-signed URL to the letter data",
59-
"responses": {
60-
"302": {
61-
"description": "Found"
62-
}
63-
},
64-
"security": [
65-
{
66-
"LambdaAuthorizer": []
67-
}
68-
],
69-
"summary": "Get letter data",
70-
"x-amazon-apigateway-integration": {
71-
"contentHandling": "CONVERT_TO_TEXT",
72-
"credentials": "${APIG_EXECUTION_ROLE_ARN}",
73-
"httpMethod": "POST",
74-
"passthroughBehavior": "WHEN_NO_TEMPLATES",
75-
"responses": {
76-
".*": {
77-
"statusCode": "200"
78-
}
79-
},
80-
"timeoutInMillis": 29000,
81-
"type": "AWS_PROXY",
82-
"uri": "arn:aws:apigateway:${AWS_REGION}:lambda:path/2015-03-31/functions/${GET_LETTER_DATA_LAMBDA_ARN}/invocations"
83-
}
84-
},
8557
"parameters": [
8658
{
8759
"description": "Unique identifier of this resource",
@@ -133,6 +105,50 @@
133105
"uri": "arn:aws:apigateway:${AWS_REGION}:lambda:path/2015-03-31/functions/${PATCH_LETTER_LAMBDA_ARN}/invocations"
134106
}
135107
}
108+
},
109+
"/letters/{id}/data": {
110+
"get": {
111+
"operationId": "getDataId",
112+
"responses": {
113+
"303": {
114+
"description": "See Other",
115+
"headers": {
116+
"Location": {
117+
"description": "The signed S3 URL of the data file to download",
118+
"example": "https://examples3bucket.com/filelocation",
119+
"schema": {
120+
"type": "string"
121+
}
122+
}
123+
}
124+
},
125+
"404": {
126+
"description": "Resource not found"
127+
},
128+
"429": {
129+
"description": "Too many requests"
130+
},
131+
"500": {
132+
"description": "Server error"
133+
}
134+
},
135+
"summary": "Fetch a data file",
136+
"tags": [
137+
"data"
138+
]
139+
},
140+
"parameters": [
141+
{
142+
"description": "Unique identifier of this resource",
143+
"in": "path",
144+
"name": "id",
145+
"required": true,
146+
"schema": {
147+
"example": "24L5eYSWGzCHlGmzNxuqVusPxDg",
148+
"type": "string"
149+
}
150+
}
151+
]
136152
}
137153
}
138154
}

lambdas/api-handler/src/handlers/__tests__/get-letter-data.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('API Lambda handler', () => {
3131
jest.resetModules();
3232
});
3333

34-
it('returns 302 Found with a pre signed url', async () => {
34+
it('returns 303 Found with a pre signed url', async () => {
3535

3636
const mockedGetLetterDataUrlService = letterService.getLetterDataUrl as jest.Mock;
3737
mockedGetLetterDataUrlService.mockResolvedValue('https://somePreSignedUrl.com');
@@ -46,7 +46,7 @@ describe('API Lambda handler', () => {
4646
const result = await getLetterData(event, context, callback);
4747

4848
expect(result).toEqual({
49-
statusCode: 302,
49+
statusCode: 303,
5050
Location: 'https://somePreSignedUrl.com',
5151
body: ''
5252
});

lambdas/api-handler/src/handlers/get-letter-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const getLetterData: APIGatewayProxyHandler = async (event) => {
2121
const letterId = assertNotEmpty( event.pathParameters?.id, new ValidationError(ApiErrorDetail.InvalidRequestMissingLetterIdPathParameter));
2222

2323
return {
24-
statusCode: 302,
24+
statusCode: 303,
2525
Location: await getLetterDataUrl(supplierId, letterId, letterRepo),
2626
body: ''
2727
};

0 commit comments

Comments
 (0)