diff --git a/backend/index.js b/backend/index.js index 59c02b1..2218a5c 100644 --- a/backend/index.js +++ b/backend/index.js @@ -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); diff --git a/start_latest.sh b/start_latest.sh new file mode 100755 index 0000000..ec020ee --- /dev/null +++ b/start_latest.sh @@ -0,0 +1,12 @@ +git reset HEAD --hard && +git pull && +cd backend && +rm -r ./frontend && +mkdir frontend && +yarn install && +cd ../frontend && +yarn install && +yarn run build && +mv ./build/* ../backend/frontend && +cd ../backend && +yarn start diff --git a/update.sh b/update.sh deleted file mode 100755 index f7cd18f..0000000 --- a/update.sh +++ /dev/null @@ -1,14 +0,0 @@ -BACKENDID = netstat -tulpn 2>/dev/null | grep ":3001 " | awk '{print $7;}' | cut -d "/" -f1 -kill -9 $BACKENDID -git reset HEAD --hard -git pull -cd backend -rm -r ./frontend -mkdir frontend -yarn install -cd ../frontend -yarn install -yarn run build -mv ./build/* ../backend/frontend -cd ../backend -yarn start