@@ -22,14 +22,15 @@ Start your API server with I/O schema validation and custom middlewares in minut
2222 3 . [ Options] ( #options )
2323 4 . [ Using native express middlewares] ( #using-native-express-middlewares )
2424 5 . [ Refinements] ( #refinements )
25- 6 . [ Transformations] ( #transformations )
26- 7 . [ Top level transformations and mapping] ( #top-level-transformations-and-mapping )
27- 8 . [ Dealing with dates] ( #dealing-with-dates )
28- 9 . [ Cross-Origin Resource Sharing] ( #cross-origin-resource-sharing ) (CORS)
29- 10 . [ Enabling HTTPS] ( #enabling-https )
30- 11 . [ Enabling compression] ( #enabling-compression )
31- 12 . [ Customizing logger] ( #customizing-logger )
32- 13 . [ Child logger] ( #child-logger )
25+ 6 . [ Query string parser] ( #query-string-parser )
26+ 7 . [ Transformations] ( #transformations )
27+ 8 . [ Top level transformations and mapping] ( #top-level-transformations-and-mapping )
28+ 9 . [ Dealing with dates] ( #dealing-with-dates )
29+ 10 . [ Cross-Origin Resource Sharing] ( #cross-origin-resource-sharing ) (CORS)
30+ 11 . [ Enabling HTTPS] ( #enabling-https )
31+ 12 . [ Enabling compression] ( #enabling-compression )
32+ 13 . [ Customizing logger] ( #customizing-logger )
33+ 14 . [ Child logger] ( #child-logger )
33345 . [ Advanced features] ( #advanced-features )
3435 1 . [ Customizing input sources] ( #customizing-input-sources )
3536 2 . [ Headers as input source] ( #headers-as-input-source )
@@ -491,24 +492,31 @@ const endpoint = endpointsFactory.build({
491492});
492493```
493494
495+ ## Query string parser
496+
497+ In Express 5 the default query string parser was changed from "extended" (which is the ` qs ` module) to "simple" (which
498+ is the ` node:querystring ` module). The "extended" parser supports nested objects and arrays with optional indexes in
499+ square brackets. You can choose between those parsers as well as configure a custom implementation:
500+
501+ | ` queryParser ` value | Query string example for arrays |
502+ | -------------------------------------- | ------------------------------------------------ |
503+ | simple | ` ?values=1&values=2&values=3 ` |
504+ | extended | as simple or ` ?values[]=1&values[]=2&values[]=3 ` |
505+ | ` (str) => qs.parse(str, {comma:true}) ` | as extended or ` ?values=1,2,3 ` |
506+
494507## Transformations
495508
496- Since parameters of GET requests come in the form of strings, there is often a need to transform them into numbers or
497- arrays of numbers.
509+ Since parameters of GET requests come in the form of strings, there is often a need to transform them into numbers.
498510
499511``` typescript
500512import { z } from " zod" ;
501513
502- const getUserEndpoint = endpointsFactory .build ({
514+ const getUserEndpoint = endpointsFactory .buildVoid ({
503515 input: z .object ({
504516 id: z .string ().transform ((id ) => parseInt (id , 10 )),
505- ids: z
506- .string ()
507- .transform ((ids ) => ids .split (" ," ).map ((id ) => parseInt (id , 10 ))),
508517 }),
509- handler : async ({ input : { id , ids }, logger }) => {
510- logger .debug (" id" , id ); // type: number
511- logger .debug (" ids" , ids ); // type: number[]
518+ handler : async ({ input : { id }, logger }) => {
519+ logger .debug (" id" , typeof id ); // number
512520 },
513521});
514522```
0 commit comments