SeungJun Baek

라우팅 #1

...@@ -32,5 +32,6 @@ babel을 통해 내 최신js 코드를 호환성이 좋은 구 버전 js코드 ...@@ -32,5 +32,6 @@ babel을 통해 내 최신js 코드를 호환성이 좋은 구 버전 js코드
32 32
33 /movies: 영화 보여주는 페이지 33 /movies: 영화 보여주는 페이지
34 /movies/:id 영화 상세정보 34 /movies/:id 영화 상세정보
35 +
35 /users/:id 사용자 상세정보 36 /users/:id 사용자 상세정보
36 /users/likemovie 사용자가 좋아하는 영화 목록 37 /users/likemovie 사용자가 좋아하는 영화 목록
...\ No newline at end of file ...\ No newline at end of file
......
1 +export const home = (req,res)=>{
2 + return res.send("hello this is homepage!");
3 +}
4 +
5 +export const join= (req,res) =>{
6 + return res.send("hello this is joinpage!");
7 +}
8 +
9 +export const login = (req,res)=>{
10 + return res.send("hello this is login!");
11 +}
...\ No newline at end of file ...\ No newline at end of file
1 +export const showMovies = (req,res) =>{
2 + res.send("movies");
3 +}
...\ No newline at end of file ...\ No newline at end of file
1 +import express from "express";
2 +import {home,join,login} from "../controllers/globalController"
3 +const globalRouter = express.Router();
4 +
5 +globalRouter.get('/',home);
6 +globalRouter.get('/join',join);
7 +globalRouter.get('/login',login);
8 +export default globalRouter
...\ No newline at end of file ...\ No newline at end of file
1 +import express from "express";
2 +import { showMovies } from "../controllers/movieController";
3 +
4 +const movieRouter = express.Router();
5 +
6 +movieRouter.get('/',showMovies);
7 +
8 +export default movieRouter;
...\ No newline at end of file ...\ No newline at end of file
1 import express from "express" 1 import express from "express"
2 - 2 +import global from "./routers/globalRouter";
3 -const app = express(); 3 +import movies from "./routers/movieRouter";
4 4
5 const PORT = 3000 5 const PORT = 3000
6 +const app = express();
7 +app.use('/',global);
8 +app.use('/movies',movies);
6 9
7 -app.listen(PORT,() => console.log(`The Server is running on http://localhost:${PORT} 🚀`))
...\ No newline at end of file ...\ No newline at end of file
10 +app.listen(PORT,() => console.log(`The Server is running on http://localhost:${PORT}`));
......
1 { 1 {
2 - "exec":"npx babel-node server.js" 2 + "exec":"npx babel-node backend/server.js"
3 } 3 }
4 4
......