aboutsummaryrefslogtreecommitdiff
path: root/src/server.js
diff options
context:
space:
mode:
authorMark Powers <markppowers0@gmail.com>2019-11-03 12:07:24 -0600
committerMark Powers <markppowers0@gmail.com>2019-11-03 12:07:24 -0600
commit5c138373b366547190fbc655c19a25a7a7ab4996 (patch)
tree4ff10774a988278536d08a905c43b5bdfe10d9bd /src/server.js
parent316cb898d2439a28751b60511540e5fd3446cd9e (diff)
Add word squares
Diffstat (limited to 'src/server.js')
-rw-r--r--src/server.js15
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"))