Refactor search and doc controllers to allow for post-processing middleware
to handle geojson and response sending. Allows for a much more flexible routing scheme.
(app, middleware/access_log).js
-Move the logic that determines whether access logging is
necessary to app.js, since that allows us to maintain the style
of `app.use(require(/* desired middleware module */))` inside
`app.js` without returning a "noop" middleware from
`middleware/access_log.js` in the case that it's unnecessary.
(query, query)/*.js
-Remove unused `../src/logger` `require()`s.
src/logger.js, package.json
-Remove `src/logger` in favor of using `pelias-logger` for all
logging, since it's the Pelias standard.
middleware/500.js
-Replace usage of `src/logger` with pelias-logger.
middleware/500.js
-cf1a483 changed the middleware to return an opaque error
message rather than the error object itself, in case it contains
sensitive information. The problem is that some sanitizers
return a helpful error message (intended to be seen by users) as
a string. Add a conditional to only return the ambiguous,
catchall error message when a non-string `err` object is
received -- this will likely be a stack trace, or something.
middleware/500.js
-Add code to the 500 catchall middleware to report errors to
stdout/stderr.
-Also, stringify the error via `.toString()` before passing it
to `res.json()`, since otherwise an empty object appears to be
returned.