@@ -107,21 +107,21 @@ api.delete('/test/:test/:test2', function(req,res) {
107
107
108
108
api . get ( '/test/:test/query' , function ( req , res ) {
109
109
// console.log(req)
110
- res . status ( 200 ) . json ( { method : 'get' , status : 'ok' , param : req . params . test , query : req . query . test ? req . query . test : req . multiValueQuery . test } )
110
+ res . status ( 200 ) . json ( { method : 'get' , status : 'ok' , param : req . params . test , query : req . query , multiValueQuery : req . multiValueQuery } )
111
111
} )
112
112
113
113
api . post ( '/test/:test/query' , function ( req , res ) {
114
114
// console.log(req)
115
- res . status ( 200 ) . json ( { method : 'post' , status : 'ok' , param : req . params . test , query : req . query . test ? req . query . test : req . multiValueQuery . test } )
115
+ res . status ( 200 ) . json ( { method : 'post' , status : 'ok' , param : req . params . test , query : req . query , multiValueQuery : req . multiValueQuery } )
116
116
} )
117
117
118
118
api . put ( '/test/:test/query' , function ( req , res ) {
119
119
// console.log(req)
120
- res . status ( 200 ) . json ( { method : 'put' , status : 'ok' , param : req . params . test , query : req . query . test ? req . query . test : req . multiValueQuery . test } )
120
+ res . status ( 200 ) . json ( { method : 'put' , status : 'ok' , param : req . params . test , query : req . query , multiValueQuery : req . multiValueQuery } )
121
121
} )
122
122
123
123
api . options ( '/test/:test/query' , function ( req , res ) {
124
- res . status ( 200 ) . json ( { method : 'options' , status : 'ok' , param : req . params . test , query : req . query . test ? req . query . test : req . multiValueQuery . test } )
124
+ res . status ( 200 ) . json ( { method : 'options' , status : 'ok' , param : req . params . test , query : req . query , multiValueQuery : req . multiValueQuery } )
125
125
} )
126
126
127
127
api . get ( '/test/:test/query/:test2' , function ( req , res ) {
@@ -312,13 +312,13 @@ describe('Route Tests:', function() {
312
312
it ( 'Path with parameter and querystring: /test/123/query/?test=321' , async function ( ) {
313
313
let _event = Object . assign ( { } , event , { path : '/test/123/query' , queryStringParameters : { test : '321' } } )
314
314
let result = await new Promise ( r => api . run ( _event , { } , ( e , res ) => { r ( res ) } ) )
315
- expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"get","status":"ok","param":"123","query":" 321"}' , isBase64Encoded : false } )
315
+ expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"get","status":"ok","param":"123","query":{"test":" 321"},"multiValueQuery":{"test":["321"]} }' , isBase64Encoded : false } )
316
316
} ) // end it
317
317
318
318
it ( 'Path with parameter and multiple querystring: /test/123/query/?test=123&test=321' , async function ( ) {
319
319
let _event = Object . assign ( { } , event , { path : '/test/123/query' , multiValueQueryStringParameters : { test : [ '123' , '321' ] } } )
320
320
let result = await new Promise ( r => api . run ( _event , { } , ( e , res ) => { r ( res ) } ) )
321
- expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"get","status":"ok","param":"123","query":["123","321"]}' , isBase64Encoded : false } )
321
+ expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"get","status":"ok","param":"123","query":{"test":"321"},"multiValueQuery":{"test": ["123","321"]} }' , isBase64Encoded : false } )
322
322
} ) // end it
323
323
324
324
it ( 'Path with multiple parameters and querystring: /test/123/query/456/?test=321' , async function ( ) {
@@ -331,13 +331,13 @@ describe('Route Tests:', function() {
331
331
it ( 'Event path + querystring w/ trailing slash (this shouldn\'t happen with API Gateway)' , async function ( ) {
332
332
let _event = Object . assign ( { } , event , { path : '/test/123/query/?test=321' , queryStringParameters : { test : '321' } } )
333
333
let result = await new Promise ( r => api . run ( _event , { } , ( e , res ) => { r ( res ) } ) )
334
- expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"get","status":"ok","param":"123","query":" 321"}' , isBase64Encoded : false } )
334
+ expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"get","status":"ok","param":"123","query":{"test":" 321"},"multiValueQuery":{"test":["321"]} }' , isBase64Encoded : false } )
335
335
} ) // end it
336
336
337
337
it ( 'Event path + querystring w/o trailing slash (this shouldn\'t happen with API Gateway)' , async function ( ) {
338
338
let _event = Object . assign ( { } , event , { path : '/test/123/query?test=321' , queryStringParameters : { test : '321' } } )
339
339
let result = await new Promise ( r => api . run ( _event , { } , ( e , res ) => { r ( res ) } ) )
340
- expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"get","status":"ok","param":"123","query":" 321"}' , isBase64Encoded : false } )
340
+ expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"get","status":"ok","param":"123","query":{"test":" 321"},"multiValueQuery":{"test":["321"]} }' , isBase64Encoded : false } )
341
341
} ) // end it
342
342
343
343
@@ -490,13 +490,13 @@ describe('Route Tests:', function() {
490
490
it ( 'Path with parameter and querystring: /test/123/query/?test=321' , async function ( ) {
491
491
let _event = Object . assign ( { } , event , { path : '/test/123/query' , httpMethod : 'post' , queryStringParameters : { test : '321' } } )
492
492
let result = await new Promise ( r => api . run ( _event , { } , ( e , res ) => { r ( res ) } ) )
493
- expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"post","status":"ok","param":"123","query":" 321"}' , isBase64Encoded : false } )
493
+ expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"post","status":"ok","param":"123","query":{"test":" 321"},"multiValueQuery":{"test":["321"]} }' , isBase64Encoded : false } )
494
494
} ) // end it
495
495
496
496
it ( 'Path with parameter and multiple querystring: /test/123/query/?test=123&test=321' , async function ( ) {
497
497
let _event = Object . assign ( { } , event , { path : '/test/123/query' , httpMethod : 'post' , multiValueQueryStringParameters : { test : [ '123' , '321' ] } } )
498
498
let result = await new Promise ( r => api . run ( _event , { } , ( e , res ) => { r ( res ) } ) )
499
- expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"post","status":"ok","param":"123","query":["123","321"]}' , isBase64Encoded : false } )
499
+ expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"post","status":"ok","param":"123","query":{"test":"321"},"multiValueQuery":{"test": ["123","321"]} }' , isBase64Encoded : false } )
500
500
} ) // end it
501
501
502
502
it ( 'Path with multiple parameters and querystring: /test/123/query/456/?test=321' , async function ( ) {
@@ -605,13 +605,13 @@ describe('Route Tests:', function() {
605
605
it ( 'Path with parameter and querystring: /test/123/query/?test=321' , async function ( ) {
606
606
let _event = Object . assign ( { } , event , { path : '/test/123/query' , httpMethod : 'put' , queryStringParameters : { test : '321' } } )
607
607
let result = await new Promise ( r => api . run ( _event , { } , ( e , res ) => { r ( res ) } ) )
608
- expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"put","status":"ok","param":"123","query":" 321"}' , isBase64Encoded : false } )
608
+ expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"put","status":"ok","param":"123","query":{"test":" 321"},"multiValueQuery":{"test":["321"]} }' , isBase64Encoded : false } )
609
609
} ) // end it
610
610
611
611
it ( 'Path with parameter and multiple querystring: /test/123/query/?test=123&test=321' , async function ( ) {
612
612
let _event = Object . assign ( { } , event , { path : '/test/123/query' , httpMethod : 'put' , multiValueQueryStringParameters : { test : [ '123' , '321' ] } } )
613
613
let result = await new Promise ( r => api . run ( _event , { } , ( e , res ) => { r ( res ) } ) )
614
- expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"put","status":"ok","param":"123","query":["123","321"]}' , isBase64Encoded : false } )
614
+ expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"put","status":"ok","param":"123","query":{"test":"321"},"multiValueQuery":{"test": ["123","321"]} }' , isBase64Encoded : false } )
615
615
} ) // end it
616
616
617
617
it ( 'Path with multiple parameters and querystring: /test/123/query/456/?test=321' , async function ( ) {
@@ -752,13 +752,13 @@ describe('Route Tests:', function() {
752
752
it ( 'Path with parameter and querystring: /test/123/query/?test=321' , async function ( ) {
753
753
let _event = Object . assign ( { } , event , { path : '/test/123/query' , httpMethod : 'options' , queryStringParameters : { test : '321' } } )
754
754
let result = await new Promise ( r => api . run ( _event , { } , ( e , res ) => { r ( res ) } ) )
755
- expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"options","status":"ok","param":"123","query":" 321"}' , isBase64Encoded : false } )
755
+ expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"options","status":"ok","param":"123","query":{"test":" 321"},"multiValueQuery":{"test":["321"]} }' , isBase64Encoded : false } )
756
756
} ) // end it
757
757
758
758
it ( 'Path with parameter and multiple querystring: /test/123/query/?test=123&test=321' , async function ( ) {
759
759
let _event = Object . assign ( { } , event , { path : '/test/123/query' , httpMethod : 'options' , multiValueQueryStringParameters : { test : [ '123' , '321' ] } } )
760
760
let result = await new Promise ( r => api . run ( _event , { } , ( e , res ) => { r ( res ) } ) )
761
- expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"options","status":"ok","param":"123","query":["123","321"]}' , isBase64Encoded : false } )
761
+ expect ( result ) . to . deep . equal ( { headers : { 'content-type' : 'application/json' } , statusCode : 200 , body : '{"method":"options","status":"ok","param":"123","query":{"test":"321"},"multiValueQuery":{"test": ["123","321"]} }' , isBase64Encoded : false } )
762
762
} ) // end it
763
763
764
764
it ( 'Path with multiple parameters and querystring: /test/123/query/456/?test=321' , async function ( ) {
0 commit comments