File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ void describe('aProblem()', () => {
1414 statusCode : 409 ,
1515 headers : {
1616 'content-type' : 'application/problem+json' ,
17- 'Cache-Control' : 'public, max-age=60' ,
17+ // 'Cache-Control': 'public, max-age=60',
18+ 'Cache-Control' : 'no-store' ,
1819 } ,
1920 body : JSON . stringify ( {
2021 '@context' : Context . problemDetail . toString ( ) ,
@@ -23,4 +24,20 @@ void describe('aProblem()', () => {
2324 } ) ,
2425 } ,
2526 ) )
27+
28+ void it ( 'can set cache control' , ( ) =>
29+ assert . partialDeepStrictEqual (
30+ aProblem (
31+ {
32+ title : `A Conflict!` ,
33+ status : 409 ,
34+ } ,
35+ 60 ,
36+ ) ,
37+ {
38+ headers : {
39+ 'Cache-Control' : 'public, max-age=60' ,
40+ } ,
41+ } ,
42+ ) )
2643} )
Original file line number Diff line number Diff line change @@ -4,12 +4,13 @@ import type { APIGatewayProxyStructuredResultV2 } from 'aws-lambda'
44
55export const aProblem = (
66 problem : Omit < Static < typeof ProblemDetail > , '@context' > ,
7- cacheForSeconds : number = 60 ,
7+ cacheForSeconds : number = 0 ,
88) : APIGatewayProxyStructuredResultV2 => ( {
99 statusCode : problem . status ,
1010 headers : {
1111 'content-type' : 'application/problem+json' ,
12- 'Cache-Control' : `public, max-age=${ cacheForSeconds } ` ,
12+ 'Cache-Control' :
13+ cacheForSeconds > 0 ? `public, max-age=${ cacheForSeconds } ` : 'no-store' ,
1314 } ,
1415 body : JSON . stringify ( {
1516 '@context' : Context . problemDetail . toString ( ) ,
You can’t perform that action at this time.
0 commit comments