pelias / api

HTTP API for Pelias Geocoder
http://pelias.io
MIT License
221 stars 162 forks source link

pelias-parser: print parser solutions in API debug output #1583

Closed missinglink closed 2 years ago

missinglink commented 2 years ago

The pelias-parser CLI has a nice debug output of all the solutions generated, however this isn't available via the API debug view, this is annoying since it requires copy->pasting the input across to the terminal to inspect the parser behaviour.

In the past I thought we couldn't really take advantage of the Debug functionality in the sanitizer/* modules because we don't have access to req like we do in the middleware/* modules.

The minor change I made to sanitizer/sanitizeAll.js in this PR exposes the req param to all sanitisers in a backward compatible way.

The rest of this PR is an implementation of that workflow where we use the same logic from the parser CLI to print a concise summary of each solution.

Screenshot 2021-11-15 at 14 00 44
missinglink commented 2 years ago

played around with a few versions, quite happy with this:

Screenshot 2021-11-15 at 15 02 11