Showing
24 changed files
with
112 additions
and
22 deletions
... | @@ -3,20 +3,22 @@ import morgan from "morgan"; | ... | @@ -3,20 +3,22 @@ import morgan from "morgan"; |
3 | import helmet from "helmet"; | 3 | import helmet from "helmet"; |
4 | import cookieParser from "cookie-parser"; | 4 | import cookieParser from "cookie-parser"; |
5 | import bodyParser from "body-parser"; | 5 | import bodyParser from "body-parser"; |
6 | +import { localsMiddleware } from "./middlewares"; | ||
7 | +import routes from "./routes"; | ||
6 | import userRouter from "./routers/userRouter"; | 8 | import userRouter from "./routers/userRouter"; |
7 | import videoRouter from "./routers/videoRouter"; | 9 | import videoRouter from "./routers/videoRouter"; |
8 | import globalRouter from "./routers/globalRouter"; | 10 | import globalRouter from "./routers/globalRouter"; |
9 | -import routes from "./routes"; | ||
10 | -const app = express(); | ||
11 | 11 | ||
12 | +const app = express(); | ||
12 | 13 | ||
14 | +app.use(helmet()); | ||
15 | +app.set("view engine", "pug"); | ||
13 | app.use(cookieParser()); | 16 | app.use(cookieParser()); |
14 | app.use(bodyParser.json()); | 17 | app.use(bodyParser.json()); |
15 | app.use(bodyParser.urlencoded({ extended: true })); //json, html, text, urlencoded 할 거 없이 다 parser할 수 있도록 설정해줘야 한다. | 18 | app.use(bodyParser.urlencoded({ extended: true })); //json, html, text, urlencoded 할 거 없이 다 parser할 수 있도록 설정해줘야 한다. |
16 | -app.use(helmet()); | ||
17 | app.use(morgan("dev")); | 19 | app.use(morgan("dev")); |
18 | 20 | ||
19 | - | 21 | +app.use(localsMiddleware); |
20 | app.use(routes.home, globalRouter); | 22 | app.use(routes.home, globalRouter); |
21 | app.use(routes.users, userRouter); | 23 | app.use(routes.users, userRouter); |
22 | app.use(routes.videos, videoRouter); | 24 | app.use(routes.videos, videoRouter); | ... | ... |
1 | -export const join = (req, res) => res.send("join"); | ||
2 | -export const login = (req, res) => res.send("login"); | ||
3 | -export const logout = (req, res) => res.send("logout"); | ||
4 | -export const users = (req, res) => res.send("users"); | ||
5 | -export const userDetail = (req, res) => res.send("user Detail"); | ||
6 | -export const editProfile = (req, res) => res.send("Edit Profile"); | ||
7 | -export const changePassword = (req, res) => res.send("Change Password"); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +export const join = (req, res) => res.render("join"); | ||
2 | +export const login = (req, res) => res.render("login"); | ||
3 | +export const logout = (req, res) => res.render("logout"); | ||
4 | +export const users = (req, res) => res.render("users"); | ||
5 | +export const userDetail = (req, res) => res.render("userDetail"); | ||
6 | +export const editProfile = (req, res) => res.render("editProfile"); | ||
7 | +export const changePassword = (req, res) => res.render("changePassword"); | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | -export const home = (req, res) => res.send("home"); | ||
2 | -export const search = (req, res) => res.send("search"); | ||
3 | -export const videos = (req, res) => res.send("videos"); | ||
4 | -export const upload = (req, res) => res.send("upload"); | ||
5 | -export const videoDetail = (req, res) => res.send("videoDetail"); | ||
6 | -export const editVideo = (req, res) => res.send("editVideo"); | ||
7 | -export const deleteVideo = (req, res) => res.send("deleteVideo"); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +export const home = (req, res) => res.render("home"); | ||
2 | +export const search = (req, res) => res.render("search"); | ||
3 | +export const videos = (req, res) => res.render("videos"); | ||
4 | +export const upload = (req, res) => res.render("upload"); | ||
5 | +export const videoDetail = (req, res) => res.render("videoDetail"); | ||
6 | +export const editVideo = (req, res) => res.render("editVideo"); | ||
7 | +export const deleteVideo = (req, res) => res.render("deleteVideo"); | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
middlewares.js
0 → 100644
... | @@ -20,9 +20,10 @@ | ... | @@ -20,9 +20,10 @@ |
20 | "cookie-parser": "^1.4.5", | 20 | "cookie-parser": "^1.4.5", |
21 | "express": "^4.17.1", | 21 | "express": "^4.17.1", |
22 | "helmet": "^3.22.0", | 22 | "helmet": "^3.22.0", |
23 | - "morgan": "^1.10.0" | 23 | + "morgan": "^1.10.0", |
24 | + "pug": "^2.0.4" | ||
24 | }, | 25 | }, |
25 | "devDependencies": { | 26 | "devDependencies": { |
26 | "nodemon": "^2.0.4" | 27 | "nodemon": "^2.0.4" |
27 | } | 28 | } |
28 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
29 | +} | ... | ... |
... | @@ -4,7 +4,6 @@ import { users, userDetail, editProfile, changePassword } from "../controllers/u | ... | @@ -4,7 +4,6 @@ import { users, userDetail, editProfile, changePassword } from "../controllers/u |
4 | 4 | ||
5 | const userRouter = express.Router(); | 5 | const userRouter = express.Router(); |
6 | 6 | ||
7 | - | ||
8 | userRouter.get(routes.users, users); | 7 | userRouter.get(routes.users, users); |
9 | userRouter.get(routes.userDetail, userDetail); | 8 | userRouter.get(routes.userDetail, userDetail); |
10 | userRouter.get(routes.editProfile, editProfile); | 9 | userRouter.get(routes.editProfile, editProfile); | ... | ... |
... | @@ -11,5 +11,4 @@ videoRouter.get(routes.videoDetail, videoDetail); | ... | @@ -11,5 +11,4 @@ videoRouter.get(routes.videoDetail, videoDetail); |
11 | videoRouter.get(routes.editVideo, editVideo); | 11 | videoRouter.get(routes.editVideo, editVideo); |
12 | videoRouter.get(routes.deleteVideo, deleteVideo); | 12 | videoRouter.get(routes.deleteVideo, deleteVideo); |
13 | 13 | ||
14 | - | ||
15 | export default videoRouter; | 14 | export default videoRouter; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
views/changePassword.pug
0 → 100644
views/deleteVideo.pug
0 → 100644
views/editProfile.pug
0 → 100644
views/editVideo.pug
0 → 100644
views/home.pug
0 → 100644
views/join.pug
0 → 100644
views/layouts/main.pug
0 → 100644
1 | +//공통되는 코드가 필요한 경우div | ||
2 | + | ||
3 | +doctype html | ||
4 | +html | ||
5 | + head | ||
6 | + <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous"> | ||
7 | + title | #{siteName} | ||
8 | + body | ||
9 | + include ../partials/header | ||
10 | + main | ||
11 | + block content | ||
12 | + include ../partials/footer |
views/login.pug
0 → 100644
views/logout.pug
0 → 100644
views/partials/footer.pug
0 → 100644
views/partials/header.pug
0 → 100644
views/search.pug
0 → 100644
views/upload.pug
0 → 100644
views/userDetail.pug
0 → 100644
views/users.pug
0 → 100644
views/videoDetail.pug
0 → 100644
views/videos.pug
0 → 100644
-
Please register or login to post a comment