I am using simple:json-routes to implement a REST API which accepts a Content-Type: application/json POST request.
My issue is that when the incoming request has badly formatted JSON, I get a traceback in the body of the error message:
SyntaxError: Unexpected token ] at Object.parse (native) at /home/sysop/.meteor/packages/simple_json-routes/.126.96.36.199gnufi++os+web.browser+web.cordova/npm/node_modules/connect/lib/middleware/json.js:85:25 at IncomingMessage.onEnd (/home/sysop/.meteor/packages/simple_json-routes/.188.8.131.52gnufi++os+web.browser+web.cordova/npm/node_modules/connect/node_modules/raw-body/index.js:57:7) at IncomingMessage.g (events.js:180:16) at IncomingMessage.emit (events.js:92:17) at _stream_readable.js:944:16 at process._tickCallback (node.js:442:13)
I would prefer not to expose this, but this is happening before I get into my code in the JsonRoutes.add() callback.
How can I get rid of this and just return the 400 Bad Request status?