diff options
author | LarsVomMars | 2020-10-07 23:42:34 +0200 |
---|---|---|
committer | LarsVomMars | 2020-10-07 23:42:34 +0200 |
commit | e6626356d90fcc58db1dbfad35211c0b3a103aa7 (patch) | |
tree | 8b599b4c43763e7434f2228ee3fbfe8304775294 /profile/index.js | |
parent | 68b06d4cdd24607cee4f016425c4380aea6d556d (diff) |
User profile boilerplate
Diffstat (limited to 'profile/index.js')
-rw-r--r-- | profile/index.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/profile/index.js b/profile/index.js new file mode 100644 index 0000000..4bfc1f7 --- /dev/null +++ b/profile/index.js @@ -0,0 +1,34 @@ +const express = require("express"); +const db = require("../db"); +const app = express.Router(); + +app.use("/", express.static(__dirname + "/public/")); + +// Basic API +app.get("/api/user", async (req, res) => {}); + +app.get("/api/questions", async (req, res) => { + const questions = await db.query("SELECT id, question FROM profile_questions"); + const answers = await db.query("SELECT answer, question_id FROM profile_answers WHERE user_id = ?", [req.session.uid]); + + for (const answer of answers) { + const qid = questions.findIndex((question) => question.id === answer.question_id); + if (qid !== undefined) questions[qid].answer = answer.answer; + } + res.json(questions); +}); + +app.post("/api/add", async (req, res) => {}); + +app.put("/api/update", async (req, res) => {}); + +// Comments API +app.get("/api/comments/:uid", async (req, res) => {}); + +app.post("/api/comment", async (req, res) => {}); + +app.put("/api/comment", async (req, res) => {}); + +app.delete("/api/comment", async (req, res) => {}); + +module.exports = app;
\ No newline at end of file |