diff --git a/app.js b/app.js index e3e6620..7f19ed4 100644 --- a/app.js +++ b/app.js @@ -73,13 +73,14 @@ app.use("/session", new sessionAPIHandler(db)); //API: /user app.use("/user", new userAPIHandler(db)); -//define 404 for everything else or 500 on error (ugly but i think it's useful) +//'automatic' error handling and/or responding to non-implemented http calls +//i know this is ugly as hell, but it might stay for a while. app.use(function(err, req, res, next) { if(err) { console.log(err.stack); res.send(500, "Oops, an error occured."); } else { - res.send(404, "Sorry, nothing here."); + res.send(501, "Method not implemented"); } res.end(); }); diff --git a/src/User.api.js b/src/User.api.js index 3f3f678..cb4b575 100644 --- a/src/User.api.js +++ b/src/User.api.js @@ -10,7 +10,7 @@ var constructor = function(db) { if(req.method == "PUT") { var params = req.body; if(tools.reqParamsGiven(["username", "password", "email"], params) == false) { - res.send(500, JSON.stringify({ + res.send(200, JSON.stringify({ "success": false, "err": "This method needs username, password and email!" }));