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()', () => {
14
14
statusCode : 409 ,
15
15
headers : {
16
16
'content-type' : 'application/problem+json' ,
17
- 'Cache-Control' : 'public, max-age=60' ,
17
+ // 'Cache-Control': 'public, max-age=60',
18
+ 'Cache-Control' : 'no-store' ,
18
19
} ,
19
20
body : JSON . stringify ( {
20
21
'@context' : Context . problemDetail . toString ( ) ,
@@ -23,4 +24,20 @@ void describe('aProblem()', () => {
23
24
} ) ,
24
25
} ,
25
26
) )
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
+ ) )
26
43
} )
Original file line number Diff line number Diff line change @@ -4,12 +4,13 @@ import type { APIGatewayProxyStructuredResultV2 } from 'aws-lambda'
4
4
5
5
export const aProblem = (
6
6
problem : Omit < Static < typeof ProblemDetail > , '@context' > ,
7
- cacheForSeconds : number = 60 ,
7
+ cacheForSeconds : number = 0 ,
8
8
) : APIGatewayProxyStructuredResultV2 => ( {
9
9
statusCode : problem . status ,
10
10
headers : {
11
11
'content-type' : 'application/problem+json' ,
12
- 'Cache-Control' : `public, max-age=${ cacheForSeconds } ` ,
12
+ 'Cache-Control' :
13
+ cacheForSeconds > 0 ? `public, max-age=${ cacheForSeconds } ` : 'no-store' ,
13
14
} ,
14
15
body : JSON . stringify ( {
15
16
'@context' : Context . problemDetail . toString ( ) ,
You can’t perform that action at this time.
0 commit comments