Open mweibel opened 5 years ago
Hey @mweibel thanks for the pointer and sorry about the delay, I had not time to look at this deeply today, but if the integration with QS in Hapi v18 is so easy I'd say that does not worth having this plugin anymore and so it worth deprecating it. Will look into it in the following weeks.
Thanks a lot.
I think this module is still needed.
From https://hapi.dev/api?v=20.2.0#-serveroptionsqueryparser
the method must return an object where each key is a parameter and matching value is the parameter value. If the method throws, the error is used as the response or returned when request.setUrl() is called.
so it looks like hapi doeas not allow nested objects. It just allows format like this:
'q[query][search][firstname]': 'John',
'q[query][search][lastname]': 'Doe',
this seems to work
parser: (query) => {
if (!query) {
return query;
}
const parsedQuery = Object.entries(query).reduce((acc, [key, value]) => {
_.set(acc, key, value);
return acc;
}, {});
return parsedQuery;
},
Release notes: https://github.com/hapijs/hapi/issues/3871
I assume this package can be deprecated and alternatively the change to the query parser suggested?
The v18 way would be: