@@ -26,43 +26,55 @@ export default defineTestHandler(
2626 echo : body ,
2727 } ;
2828 } ,
29- async ( { assert } ) => {
29+ async ( { assert, log } ) => {
30+ log ( "→ QUERY ?table=users&limit=10 (content-type: application/json)" ) ;
3031 const res = await fetch ( "?table=users&limit=10" , {
3132 method : "QUERY" ,
3233 headers : { "content-type" : "application/json" } ,
3334 body : JSON . stringify ( { sql : "select * from nitro" } ) ,
3435 } ) ;
3536
37+ log ( `← status: ${ res . status } ${ res . statusText } ` ) ;
3638 assert ( res . ok , `Unexpected status: ${ res . status } ` ) ;
3739
3840 // Response headers round-trip to the client (RFC 10008 §2.3, §3).
41+ log ( `← Accept-Query: ${ res . headers . get ( "accept-query" ) } ` ) ;
3942 assert (
4043 res . headers . get ( "accept-query" ) === "application/json" ,
4144 `Unexpected Accept-Query: ${ res . headers . get ( "accept-query" ) } ` ,
4245 ) ;
46+ log ( `← Content-Location: ${ res . headers . get ( "content-location" ) } ` ) ;
4347 assert (
4448 ( res . headers . get ( "content-location" ) || "" ) . includes ( "table=users" ) ,
4549 `Unexpected Content-Location: ${ res . headers . get ( "content-location" ) } ` ,
4650 ) ;
4751
4852 const data = await res . json ( ) ;
53+ log ( `← body: ${ JSON . stringify ( data ) } ` ) ;
54+
55+ log ( `method seen by server: ${ data . method } ` ) ;
4956 assert ( data . method === "QUERY" , `Unexpected method: ${ data . method } ` ) ;
5057
5158 // Request header round-trip (server saw the mandatory Content-Type).
59+ log ( `request Content-Type seen by server: ${ data . contentType } ` ) ;
5260 assert (
5361 ( data . contentType || "" ) . includes ( "application/json" ) ,
5462 `Unexpected request content-type: ${ data . contentType } ` ,
5563 ) ;
5664
5765 // URL search params round-trip alongside the body.
66+ log ( `url params seen by server: ${ JSON . stringify ( data . params ) } ` ) ;
5867 assert ( data . params . table === "users" , `Unexpected table param: ${ data . params . table } ` ) ;
5968 assert ( data . params . limit === "10" , `Unexpected limit param: ${ data . params . limit } ` ) ;
6069
6170 // Body round-trip.
71+ log ( `body echoed by server: ${ JSON . stringify ( data . echo ) } ` ) ;
6272 assert (
6373 data . echo ?. sql === "select * from nitro" ,
6474 `Unexpected echo: ${ JSON . stringify ( data . echo ) } ` ,
6575 ) ;
76+
77+ log ( "all QUERY (RFC 10008) round-trips verified" ) ;
6678 } ,
6779 "server/handlers/query.ts" ,
6880) ;
0 commit comments