aboutsummaryrefslogtreecommitdiff
path: root/src/server.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/server.js')
-rw-r--r--src/server.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/server.js b/src/server.js
index 69d3968..f72f21b 100644
--- a/src/server.js
+++ b/src/server.js
@@ -163,6 +163,29 @@ function setUpRoutes(models, jwtFunctions, database) {
res.status(400).send(e.message);
}
})
+ server.get(`/expected`, async (req, res, next) => {
+ try {
+ var result = await database.query("SELECT * FROM expecteds WHERE username = '" + res.locals.user.username + "' ORDER BY `name` DESC", { type: database.QueryTypes.SELECT })
+ res.status(200).send(result);
+ next();
+ } catch (e) {
+ console.log(e)
+ res.status(400).send(e.message);
+ }
+ })
+ server.post(`/expected`, async (req, res, next) => {
+ try {
+ let item = req.body;
+ console.log(item);
+ item.username = res.locals.user.username
+ await models.expected.create(item);
+ var result = await database.query("SELECT * FROM expecteds WHERE username = '" + res.locals.user.username + "' ORDER BY `name` DESC", { type: database.QueryTypes.SELECT })
+ res.status(200).send(result);
+ } catch (e) {
+ console.log(e);
+ res.status(400).send(e.message);
+ }
+ })
server.get(`/summary`, async (req, res, next) => {
try {
res.status(200).send({