Simple:json-routes: How to avoid showing app details in REST error message?


#1

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/.1.0.3.2gnufi++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/.1.0.3.2gnufi++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?


#2

please refer http://themeteorchef.com/recipes/writing-an-api/ this post for the best way for creating REST api’s in meteor .