Planning Routes


url計画を立てる.できるだけ多くのurlを書きます.コントロールを作成します.README.md

Wetube Reloaded

 / -> Home

 /join -> Join

/login -> Login

/search -> Search

/users/:id -> See User

/users/logout -> Log Out

/users./edit -> Edit MY Profile

/users/delete -> Delete MY Profile

/videos/:id -> See Video

/videos/:id/edit -> Edit Video

/videos/:id/delete -> Delete Video

 /videos/upload -> Uplade Video
このようにしてREADME.mdファイルを修正します.
コントローラを作成します.globalRouter.jsに増加しました.
globalRouter.get("/login", login)

globalRouter.get("/search", search);
login、search関数が存在しないため、当然エラーが発生します.対応する関数を作成します.userController.js
export const login = (req, res) => res.send("Login");
videoController.js
export const search = (req, res) => res.send("Search");
globalRouter.jsも輸入が必要です.
import { join, login } from "../controllers/userController";

import { trending, search } from "../controllers/videoController";
userRouter.jsも追加されます.
userRouter.get("/logout", logout);

userRouter.get(":id", see);
logout、see関数がないので作ってあげます.userController.js
export const logout = (req, res) => res.send("Log Out");

export const see = (req, res) => res.send("See User");
userRouter.js、導入を忘れないでください.
import { edit, remove, logout, see } from "../controllers/userController";
videoRouter.jsを修正します.
videoRouter.get("/upload", upload);

videoRouter.get(":id", see);

videoRouter.get(":id/edit", edit);

videoRouter.get(":id/delete", deleteVideo);
videoController.jsに関数を追加します.
export const trending = (req, res) => res.send("Home Page Videos");

export const see = (req, res) => res.send("See");

export const edit = (req, res) => res.send("Edit");

export const search = (req, res) => res.send("Search");

export const upload = (req, res) => res.send("Upload");

export const deleteVideo = (req, res) => res.send("Delete Video"
次にvideoRouter.jsを導入する.
import { see, edit, upload, deleteVideo } from "../controllers/videoController";