@@ -12,7 +12,7 @@ test('cookies get set correctly', async (t) => {
12
12
const fastify = Fastify ( )
13
13
fastify . register ( plugin )
14
14
15
- fastify . get ( '/test1' , ( req , reply ) => {
15
+ fastify . get ( '/test1' , ( _req , reply ) => {
16
16
reply
17
17
. setCookie ( 'foo' , 'foo' , { path : '/' } )
18
18
. send ( { hello : 'world' } )
@@ -39,7 +39,7 @@ test('express cookie compatibility', async (t) => {
39
39
const fastify = Fastify ( )
40
40
fastify . register ( plugin )
41
41
42
- fastify . get ( '/espresso' , ( req , reply ) => {
42
+ fastify . get ( '/espresso' , ( _req , reply ) => {
43
43
reply
44
44
. cookie ( 'foo' , 'foo' , { path : '/' } )
45
45
. send ( { hello : 'world' } )
@@ -65,7 +65,7 @@ test('should set multiple cookies', async (t) => {
65
65
const fastify = Fastify ( )
66
66
fastify . register ( plugin )
67
67
68
- fastify . get ( '/' , ( req , reply ) => {
68
+ fastify . get ( '/' , ( _req , reply ) => {
69
69
reply
70
70
. setCookie ( 'foo' , 'foo' )
71
71
. cookie ( 'bar' , 'test' )
@@ -96,7 +96,7 @@ test('should set multiple cookies', async (t) => {
96
96
const fastify = Fastify ( )
97
97
fastify . register ( plugin )
98
98
99
- fastify . get ( '/' , ( req , reply ) => {
99
+ fastify . get ( '/' , ( _req , reply ) => {
100
100
reply
101
101
. setCookie ( 'foo' , 'foo' )
102
102
. cookie ( 'bar' , 'test' , {
@@ -135,7 +135,7 @@ test('should set multiple cookies (an array already exists)', async (t) => {
135
135
const fastify = Fastify ( )
136
136
fastify . register ( plugin )
137
137
138
- fastify . get ( '/test1' , ( req , reply ) => {
138
+ fastify . get ( '/test1' , ( _req , reply ) => {
139
139
reply
140
140
. header ( 'Set-Cookie' , [ 'bar=bar' ] )
141
141
. setCookie ( 'foo' , 'foo' , { path : '/' } )
@@ -167,7 +167,7 @@ test('cookies get set correctly with millisecond dates', async (t) => {
167
167
const fastify = Fastify ( )
168
168
fastify . register ( plugin )
169
169
170
- fastify . get ( '/test1' , ( req , reply ) => {
170
+ fastify . get ( '/test1' , ( _req , reply ) => {
171
171
reply
172
172
. setCookie ( 'foo' , 'foo' , { path : '/' , expires : Date . now ( ) + 1000 } )
173
173
. send ( { hello : 'world' } )
@@ -201,7 +201,7 @@ test('share options for setCookie and clearCookie', async (t) => {
201
201
maxAge : 36000
202
202
}
203
203
204
- fastify . get ( '/test1' , ( req , reply ) => {
204
+ fastify . get ( '/test1' , ( _req , reply ) => {
205
205
reply
206
206
. setCookie ( 'foo' , 'foo' , cookieOptions )
207
207
. clearCookie ( 'foo' , cookieOptions )
@@ -236,7 +236,7 @@ test('expires should not be overridden in clearCookie', async (t) => {
236
236
expires : Date . now ( ) + 1000
237
237
}
238
238
239
- fastify . get ( '/test1' , ( req , reply ) => {
239
+ fastify . get ( '/test1' , ( _req , reply ) => {
240
240
reply
241
241
. setCookie ( 'foo' , 'foo' , cookieOptions )
242
242
. clearCookie ( 'foo' , cookieOptions )
@@ -266,15 +266,15 @@ test('parses incoming cookies', async (t) => {
266
266
267
267
// check that it parses the cookies in the onRequest hook
268
268
for ( const hook of [ 'preValidation' , 'preHandler' ] ) {
269
- fastify . addHook ( hook , ( req , reply , done ) => {
269
+ fastify . addHook ( hook , ( req , _reply , done ) => {
270
270
t . assert . ok ( req . cookies )
271
271
t . assert . ok ( req . cookies . bar )
272
272
t . assert . strictEqual ( req . cookies . bar , 'bar' )
273
273
done ( )
274
274
} )
275
275
}
276
276
277
- fastify . addHook ( 'preParsing' , ( req , reply , payload , done ) => {
277
+ fastify . addHook ( 'preParsing' , ( req , _reply , _payload , done ) => {
278
278
t . assert . ok ( req . cookies )
279
279
t . assert . ok ( req . cookies . bar )
280
280
t . assert . strictEqual ( req . cookies . bar , 'bar' )
@@ -307,7 +307,7 @@ test('defined and undefined cookies', async (t) => {
307
307
308
308
// check that it parses the cookies in the onRequest hook
309
309
for ( const hook of [ 'preValidation' , 'preHandler' ] ) {
310
- fastify . addHook ( hook , ( req , reply , done ) => {
310
+ fastify . addHook ( hook , ( req , _reply , done ) => {
311
311
t . assert . ok ( req . cookies )
312
312
313
313
t . assert . ok ( req . cookies . bar )
@@ -319,7 +319,7 @@ test('defined and undefined cookies', async (t) => {
319
319
} )
320
320
}
321
321
322
- fastify . addHook ( 'preParsing' , ( req , reply , payload , done ) => {
322
+ fastify . addHook ( 'preParsing' , ( req , _reply , _payload , done ) => {
323
323
t . assert . ok ( req . cookies )
324
324
325
325
t . assert . ok ( req . cookies . bar )
@@ -365,7 +365,7 @@ test('does not modify supplied cookie options object', async (t) => {
365
365
const fastify = Fastify ( )
366
366
fastify . register ( plugin )
367
367
368
- fastify . get ( '/test1' , ( req , reply ) => {
368
+ fastify . get ( '/test1' , ( _req , reply ) => {
369
369
reply
370
370
. setCookie ( 'foo' , 'foo' , cookieOptions )
371
371
. send ( { hello : 'world' } )
@@ -388,7 +388,7 @@ test('cookies gets cleared correctly', async (t) => {
388
388
const fastify = Fastify ( )
389
389
fastify . register ( plugin )
390
390
391
- fastify . get ( '/test1' , ( req , reply ) => {
391
+ fastify . get ( '/test1' , ( _req , reply ) => {
392
392
reply
393
393
. clearCookie ( 'foo' )
394
394
. send ( { hello : 'world' } )
@@ -414,7 +414,7 @@ describe('cookies signature', () => {
414
414
const secret = 'bar'
415
415
fastify . register ( plugin , { secret } )
416
416
417
- fastify . get ( '/test1' , ( req , reply ) => {
417
+ fastify . get ( '/test1' , ( _req , reply ) => {
418
418
reply
419
419
. setCookie ( 'foo' , 'foo' , { signed : true } )
420
420
. send ( { hello : 'world' } )
@@ -441,7 +441,7 @@ describe('cookies signature', () => {
441
441
const secret2 = 'secret-2'
442
442
fastify . register ( plugin , { secret : [ secret1 , secret2 ] } )
443
443
444
- fastify . get ( '/test1' , ( req , reply ) => {
444
+ fastify . get ( '/test1' , ( _req , reply ) => {
445
445
reply
446
446
. setCookie ( 'foo' , 'cookieVal' , { signed : true } )
447
447
. send ( { hello : 'world' } )
@@ -643,7 +643,7 @@ test('custom signer', async (t) => {
643
643
const secret = { sign : signStub , unsign : unsignStub }
644
644
fastify . register ( plugin , { secret } )
645
645
646
- fastify . get ( '/test1' , ( req , reply ) => {
646
+ fastify . get ( '/test1' , ( _req , reply ) => {
647
647
reply
648
648
. setCookie ( 'foo' , 'bar' , { signed : true } )
649
649
. send ( { hello : 'world' } )
@@ -786,7 +786,7 @@ test('cookies set with plugin options parseOptions field', async (t) => {
786
786
}
787
787
} )
788
788
789
- fastify . get ( '/test' , ( req , reply ) => {
789
+ fastify . get ( '/test' , ( _req , reply ) => {
790
790
reply . setCookie ( 'foo' , 'foo' ) . send ( { hello : 'world' } )
791
791
} )
792
792
@@ -835,7 +835,7 @@ test('handle secure:auto of cookieOptions', async (t) => {
835
835
836
836
await fastify . register ( plugin )
837
837
838
- fastify . get ( '/test1' , ( req , reply ) => {
838
+ fastify . get ( '/test1' , ( _req , reply ) => {
839
839
reply
840
840
. setCookie ( 'foo' , 'foo' , { path : '/' , secure : 'auto' } )
841
841
. send ( )
@@ -1011,7 +1011,7 @@ test('clearCookie should include parseOptions', async (t) => {
1011
1011
maxAge : 36000
1012
1012
}
1013
1013
1014
- fastify . get ( '/test1' , ( req , reply ) => {
1014
+ fastify . get ( '/test1' , ( _req , reply ) => {
1015
1015
reply
1016
1016
. setCookie ( 'foo' , 'foo' , cookieOptions )
1017
1017
. clearCookie ( 'foo' , cookieOptions )
@@ -1055,7 +1055,7 @@ test('should update a cookie value when setCookie is called multiple times', asy
1055
1055
maxAge : 36000
1056
1056
}
1057
1057
1058
- fastify . get ( '/test1' , ( req , reply ) => {
1058
+ fastify . get ( '/test1' , ( _req , reply ) => {
1059
1059
reply
1060
1060
. setCookie ( 'foo' , 'foo' , cookieOptions )
1061
1061
. clearCookie ( 'foo' , cookieOptions )
@@ -1109,7 +1109,7 @@ test('should update a cookie value when setCookie is called multiple times (empt
1109
1109
maxAge : 36000
1110
1110
}
1111
1111
1112
- fastify . get ( '/test1' , ( req , reply ) => {
1112
+ fastify . get ( '/test1' , ( _req , reply ) => {
1113
1113
reply
1114
1114
. header ( 'Set-Cookie' , '' , cookieOptions )
1115
1115
. setCookie ( 'foo' , 'foo' , cookieOptions )
@@ -1164,7 +1164,7 @@ test('should update a cookie value when setCookie is called multiple times (non-
1164
1164
maxAge : 36000
1165
1165
}
1166
1166
1167
- fastify . get ( '/test1' , ( req , reply ) => {
1167
+ fastify . get ( '/test1' , ( _req , reply ) => {
1168
1168
reply
1169
1169
. header ( 'Set-Cookie' , 'manual=manual' , cookieOptions )
1170
1170
. setCookie ( 'foo' , 'foo' , cookieOptions )
@@ -1207,12 +1207,12 @@ test('cookies get set correctly if set inside onSend', async (t) => {
1207
1207
const fastify = Fastify ( )
1208
1208
fastify . register ( plugin )
1209
1209
1210
- fastify . addHook ( 'onSend' , async ( req , reply , payload ) => {
1210
+ fastify . addHook ( 'onSend' , async ( _req , reply , payload ) => {
1211
1211
reply . setCookie ( 'foo' , 'foo' , { path : '/' } )
1212
1212
return payload
1213
1213
} )
1214
1214
1215
- fastify . get ( '/test1' , ( req , reply ) => {
1215
+ fastify . get ( '/test1' , ( _req , reply ) => {
1216
1216
reply
1217
1217
. send ( { hello : 'world' } )
1218
1218
} )
@@ -1237,16 +1237,16 @@ test('cookies get set correctly if set inside multiple onSends', async (t) => {
1237
1237
const fastify = Fastify ( )
1238
1238
fastify . register ( plugin )
1239
1239
1240
- fastify . addHook ( 'onSend' , async ( req , reply , payload ) => {
1240
+ fastify . addHook ( 'onSend' , async ( _req , reply , _payload ) => {
1241
1241
reply . setCookie ( 'foo' , 'foo' , { path : '/' } )
1242
1242
} )
1243
1243
1244
- fastify . addHook ( 'onSend' , async ( req , reply , payload ) => {
1244
+ fastify . addHook ( 'onSend' , async ( _req , reply , payload ) => {
1245
1245
reply . setCookie ( 'foo' , 'foos' , { path : '/' } )
1246
1246
return payload
1247
1247
} )
1248
1248
1249
- fastify . get ( '/test1' , ( req , reply ) => {
1249
+ fastify . get ( '/test1' , ( _req , reply ) => {
1250
1250
reply
1251
1251
. send ( { hello : 'world' } )
1252
1252
} )
@@ -1273,7 +1273,7 @@ test('cookies get set correctly if set inside onRequest', async (t) => {
1273
1273
t . plan ( 6 )
1274
1274
1275
1275
const fastify = Fastify ( )
1276
- fastify . addHook ( 'onRequest' , async ( req , reply ) => {
1276
+ fastify . addHook ( 'onRequest' , async ( _req , reply ) => {
1277
1277
reply . setCookie ( 'foo' , 'foo' , { path : '/' } )
1278
1278
return reply . send ( { hello : 'world' } )
1279
1279
} )
@@ -1298,7 +1298,7 @@ test('do not crash if the onRequest hook is not run', async (t) => {
1298
1298
t . plan ( 2 )
1299
1299
1300
1300
const fastify = Fastify ( )
1301
- fastify . addHook ( 'onRequest' , async ( req , reply ) => {
1301
+ fastify . addHook ( 'onRequest' , async ( _req , reply ) => {
1302
1302
return reply . send ( { hello : 'world' } )
1303
1303
} )
1304
1304
0 commit comments