Lee SeJin

Router update

......@@ -16,6 +16,7 @@
"@babel/node": "^7.13.13",
"@babel/preset-env": "^7.14.1",
"express": "^4.17.1",
"morgan": "^1.10.0",
"nodemon": "^2.0.7",
"pug": "^3.0.2"
},
......
export const handleHome = (req,res)=>{
const list1 = [1,2,3,4,5]
res.render("home",{pageTitle:"Home",list1});
}
export const handleUsers = (req,res)=>{
res.render("users",{pageTitle:"Users"});
}
\ No newline at end of file
export const localsMiddleware = (req,res,next) => {
res.locals.siteName = "Dev Profile";
next();
};
\ No newline at end of file
import express from "express";
import { handleHome } from "../controllers/userController";
const globalRouter = express.Router();
globalRouter.get("/",handleHome);
globalRouter.get("/join",(req,res)=>res.render("join"));
globalRouter.get("/login",(req,res)=>res.render("login"));
export default globalRouter;
\ No newline at end of file
import express from "express";
import { handleUsers } from "../controllers/userController";
const userRouter = express.Router();
userRouter.get("/",handleUsers);
userRouter.get("/edit-profile",(req,res)=>res.render("editProfile"));
userRouter.get("/:id",(req,res)=>res.render("userDetail"));
export default userRouter;
\ No newline at end of file
import path from "path";
import express from "express";
import path from "path";
import morgan from "morgan";
import globalRouter from "./routers/globalRouter";
import userRouter from "./routers/userRouter";
import { localsMiddleware } from "./middlewares";
const PORT = 5500;
const app = express();
app.set("view engine","pug");
app.set("views", path.join(__dirname, "views"));
app.use(express.static(path.join(__dirname, "static")));
app.get("/", (req,res) => res.render("home"));
app.use(morgan("dev"));
app.use(localsMiddleware);
app.use("/", globalRouter);
app.use("/users", userRouter);
......
h1 edit Profile
\ No newline at end of file
......
......@@ -2,3 +2,5 @@ extends layouts/main
block content
h1 Welcome
each item in list1
span=item
\ No newline at end of file
......
h1 join
\ No newline at end of file
......
h1 Login
\ No newline at end of file
......
header.header
.header__wrapper
.header__column
ul
li
a(href="/join") Join
li
a(href="/login") Log In
\ No newline at end of file
......
h1 User Detail
\ No newline at end of file
......
h1 users
\ No newline at end of file