diff options
Diffstat (limited to 'profile')
-rw-r--r-- | profile/index.js | 34 | ||||
-rw-r--r-- | profile/public/index.html | 34 | ||||
-rw-r--r-- | profile/public/script.js | 0 | ||||
-rw-r--r-- | profile/public/style.css | 0 |
4 files changed, 68 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 diff --git a/profile/public/index.html b/profile/public/index.html new file mode 100644 index 0000000..30f9de8 --- /dev/null +++ b/profile/public/index.html @@ -0,0 +1,34 @@ +<!DOCTYPE html> +<html lang="de"> + +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link rel="stylesheet" href="https://unpkg.com/purecss@2.0.3/build/pure-min.css" + integrity="sha384-cg6SkqEOCV1NbJoCu11+bm0NvBRc8IYLRGXkmNrqUBfTjmMYwNKPWBTIKyw9mHNJ" crossorigin="anonymous" /> + <link rel="stylesheet" href="style.css" type="text/css" media="all" /> + <title>Steckbrief</title> +</head> + +<body> + <div class="pure-menu pure-menu-horizontal"> + <a href="/" class="pure-menu-item pure-menu-link">Home</a> + <a href="/auth/api/logout" class="pure-menu-item pure-menu-link">Logout</a> + </div> + <main> + <!-- TODO: JS switch method/action --> + <form class="pure-form pure-form-stacked" action="api/add" method="post"> + <fieldset> + <legend>Steckbrief</legend> + + <!-- TODO: Insert stuff lel --> + + <!-- TODO: Consider autosave --> + <button type="submit" class="pure-button pure-button-primary">Wohooo</button> + </fieldset> + </form> + </main> + <script src="js/script.js"></script> +</body> + +</html>
\ No newline at end of file diff --git a/profile/public/script.js b/profile/public/script.js new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/profile/public/script.js diff --git a/profile/public/style.css b/profile/public/style.css new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/profile/public/style.css |