diff options
author | Mark Powers <markppowers0@gmail.com> | 2020-10-07 10:54:15 -0500 |
---|---|---|
committer | Mark Powers <markppowers0@gmail.com> | 2020-10-07 10:54:15 -0500 |
commit | 35b6d276bdeabdf7bf5eee59d85dfefee7531fce (patch) | |
tree | d4332664d0f38d9c5738ee5ddad0d314fbe7152e /src/server.js | |
parent | 98da11b940c194f5e4bd423cb57d252df6185715 (diff) |
Add expected expenses
Diffstat (limited to 'src/server.js')
-rw-r--r-- | src/server.js | 23 |
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({ |