make backend more reliable
This commit is contained in:
@@ -144,7 +144,7 @@ passport.deserializeUser(function (id, done) {
|
||||
});
|
||||
|
||||
app.post("/API/user/login", passport.authenticate('local-login'), function (req, res) {
|
||||
res.status(status.OK).send("login success");
|
||||
return res.status(status.OK).send("login success");
|
||||
});
|
||||
|
||||
app.put("/API/user/create", function (req, res) {
|
||||
@@ -155,11 +155,11 @@ app.put("/API/user/create", function (req, res) {
|
||||
if (DEBUG) return res.status(status.OK).send();
|
||||
connection.query(`INSERT INTO user (deactivated, email, password) values (1, ${email}, ${password})`, function (err, rows) {
|
||||
if (err)
|
||||
return res.send(status.INTERNAL_SERVER_ERROR).send("the user seems to exist already - if you think this is an error contact the sys admin");
|
||||
return res.status(status.INTERNAL_SERVER_ERROR).send("the user seems to exist already - if you think this is an error contact the sys admin");
|
||||
return res.status(status.OK).send("account successfully created");
|
||||
});
|
||||
} else {
|
||||
res.status(status.BAD_REQUEST).send("invalid data supplied");
|
||||
return res.status(status.BAD_REQUEST).send("invalid data supplied");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -168,12 +168,12 @@ app.all("*", function (req, res, next) {
|
||||
return next();
|
||||
}
|
||||
else {
|
||||
res.status(status.UNAUTHORIZED).send("please log in before using this site");
|
||||
return res.status(status.UNAUTHORIZED).send("please log in before using this site");
|
||||
}
|
||||
});
|
||||
|
||||
app.get("/API/testlogin", function (req, res) {
|
||||
res.status(status.OK).send(req.user["email"]);
|
||||
return res.status(status.OK).send(req.user["email"]);
|
||||
});
|
||||
|
||||
app.get('/API/day', function (req, res) {
|
||||
@@ -190,21 +190,21 @@ app.get('/API/day', function (req, res) {
|
||||
const querystring = `SELECT time, price, quality FROM marketv2 WHERE kind = ${kind} AND time > "${daybegin}" AND time < "${dayend}" ORDER BY time, quality`;
|
||||
connection.query(querystring, function (error, results, fields) {
|
||||
if (error) {
|
||||
res.status(status.INTERNAL_SERVER_ERROR).send("database connection failed");
|
||||
return res.status(status.INTERNAL_SERVER_ERROR).send("database connection failed");
|
||||
}
|
||||
res.send(results);
|
||||
return res.send(results);
|
||||
});
|
||||
}
|
||||
else
|
||||
res.status(status.BAD_REQUEST).send("invalid data range provided");
|
||||
return res.status(status.BAD_REQUEST).send("invalid data range provided");
|
||||
|
||||
}
|
||||
else
|
||||
res.status(status.BAD_REQUEST).send("invalid data provided");
|
||||
return res.status(status.BAD_REQUEST).send("invalid data provided");
|
||||
});
|
||||
|
||||
app.get('/API/resourcelist', function (req, res) {
|
||||
res.send(resourceList);
|
||||
return res.send(resourceList);
|
||||
});
|
||||
|
||||
app.listen(3001);
|
||||
|
||||
Reference in New Issue
Block a user