diff options
Diffstat (limited to 'src/server.js')
-rw-r--r-- | src/server.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/server.js b/src/server.js index 0629d31..a735d35 100644 --- a/src/server.js +++ b/src/server.js @@ -97,6 +97,11 @@ function setUpRoutes(models, jwtFunctions, database) { server.get('/feed', (req, res) => res.sendFile(__dirname + "/html/feed.html")); server.get('/essay', (req, res) => res.sendFile(__dirname + "/html/essay.html")); server.get('/snake', (req, res) => res.sendFile(__dirname + "/html/snake.html")); + server.get('/word-square', (req, res) => res.sendFile(__dirname + "/html/word-square.html")); + server.get('/wordsquares/best', async (req, res, next) => { + var best = await database.query("select words, name from wordsquares where best = 1", { type: database.QueryTypes.SELECT }) + res.status(200).send({ best: best }); + }) server.get('/setScore', (req, res) => { request(`http://localhost:8000?${req.url.split("?")[1]}`, function (error, response, body) { }); @@ -192,6 +197,16 @@ function setUpRoutes(models, jwtFunctions, database) { console.debug("Error with email submission") } }) + server.post('/wordsquares', async (req, res, next) => { + const words = req.body.words; + const name = req.body.name; + if (name && words) { + models.wordsquares.create({"name": name, "words": words, "best": false}) + res.redirect('/wordsquare#success'); + } else { + console.debug("Error with wordsquare submission") + } + }) server.get('/favicon.ico', (req, res) => res.sendFile(__dirname + "/icon/favicon.ico")) |