diff --git a/controllers/main.js b/controllers/main.js index cb76c0a..5920c19 100644 --- a/controllers/main.js +++ b/controllers/main.js @@ -1,13 +1,21 @@ const express = require("express"); const router = express.Router(); +const pool = require("../db.js"); -router.get("/", (req, res) => { +router.get("/", async (req, res) => { const title = "main"; if (req.session.user) { const nickname = req.session.user["nickname"]; - res.render("main", {title: title, nickname: nickname}); + const goal_list = await pool.query(`SELECT * FROM goal`); + res.render("main", { + title: title, + nickname: nickname, + goal_list: goal_list[0], + }); } else { - res.render("loginMain", {title: title}); + res.render("login", { + title: title, + }); } }); diff --git a/views/loginMain.ejs b/views/loginMain.ejs deleted file mode 100644 index 10bc43d..0000000 --- a/views/loginMain.ejs +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - <%= title %> - - - - -

Main

-

- 회원가입 - 로그인 -

- - diff --git a/views/main.ejs b/views/main.ejs index 26aa630..8f38ca1 100644 --- a/views/main.ejs +++ b/views/main.ejs @@ -12,6 +12,12 @@

<%= nickname %> 로그아웃 + <% for (let i = 0; i < goal_list.length; i++) { %> +

+ <%= goal_list[i].goal_user %> : <%= goal_list[i].goal_content %>
+
+ + <% } %>