SeungJun Baek

readme 수정, 파일 정리

...@@ -4,9 +4,33 @@ ...@@ -4,9 +4,33 @@
4 4
5 영화 사이트 만들기 5 영화 사이트 만들기
6 6
7 -사용 API: https://yts.mx/ 7 +사용 API: https://www.themoviedb.org/
8 +
9 +사용 데이터베이스 mongo DB
10 +
11 +📢사용 API 기능📢
12 +
13 +1. Trending
14 +
15 +한 주 또는 한달 동안의 유행 영화 정보를 받아올 수 있다
16 +
17 +2. Discover
18 +
19 +설정한 변수들에 해당하는 영화의 목록을 가져다준다
20 +이번 프로젝트에서는 평점, 장르, 년도를 기반으로 결과값을 반환받음
21 +
22 +3. Genre
23 +
24 +각 장르별 설정된 ID값을 얻을 수 있다
25 +
26 +4. POSTER
27 +
28 +영화의 ID값을 통해 영화 포스터 이미지를 얻을 수 있다
29 +
30 +5. Detail information
31 +
32 +MovieDB내에 있는 영화의 자세한 정보가 담긴 페이지
8 33
9 -사용 데이터베이스(예비) mongo DB
10 34
11 📢 devDependencies 📢 35 📢 devDependencies 📢
12 36
...@@ -28,22 +52,13 @@ babel을 통해 내 최신js 코드를 호환성이 좋은 구 버전 js코드 ...@@ -28,22 +52,13 @@ babel을 통해 내 최신js 코드를 호환성이 좋은 구 버전 js코드
28 - [] / -> 홈 페이지 52 - [] / -> 홈 페이지
29 53
30 - [] /join -> 회원가입 54 - [] /join -> 회원가입
31 -- [] /login -> 로그인 55 +- [] /login -> 로그인
56 +- [] /logout -> 로그아웃
32 57
33 -- [] /movies: 영화 보여주는 페이지 58 +
34 - [] /movies/:id 영화 상세정보 59 - [] /movies/:id 영화 상세정보
35 -- [] /movies/:id 에 정규표현식 적용하기 60 +- [] /movies/:id 에 정규표현식 적용하기
61 +- [] /movies/discover 년도, 장르, 평점를 기반으로한 영화 검색
36 62
37 -- [] /users/:id 사용자 상세정보 -
38 -- [] /users/likemovie 사용자가 좋아하는 영화 목록
39 -
40 -
41 -pug뷰 만들기
42 -
43 -
44 -컨트롤러만들기
45 -
46 -
47 -영화 디비 활용하기
48 -
49 -몽고 db 쓰기
...\ No newline at end of file ...\ No newline at end of file
63 +- [] /users/github/start Git hub OAuth를 기반으로한 로그인 구현
64 +- [] /users/github/finish OAuth를 기반으로 전달받은 데이터를 처리하기 위한 Callback funcion
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -57,9 +57,7 @@ export const postLogin = async (req,res) => ...@@ -57,9 +57,7 @@ export const postLogin = async (req,res) =>
57 { 57 {
58 const PAGETITLE = "Login" 58 const PAGETITLE = "Login"
59 const {username,password} = req.body; 59 const {username,password} = req.body;
60 - console.log(username,password)
61 const user = await User.findOne({username}); 60 const user = await User.findOne({username});
62 - console.log(user)
63 if(!user){ 61 if(!user){
64 return res.status(400).render("login",{pageTitle:PAGETITLE,error:"An account with that username is not found"}) 62 return res.status(400).render("login",{pageTitle:PAGETITLE,error:"An account with that username is not found"})
65 } 63 }
...@@ -84,7 +82,6 @@ export const startGithubLogin = (req,res) => ...@@ -84,7 +82,6 @@ export const startGithubLogin = (req,res) =>
84 } 82 }
85 const params = new URLSearchParams(config).toString(); 83 const params = new URLSearchParams(config).toString();
86 const finalURL = `${baseURL}?${params}` 84 const finalURL = `${baseURL}?${params}`
87 - console.log(finalURL);
88 return res.redirect(finalURL); 85 return res.redirect(finalURL);
89 } 86 }
90 87
...@@ -99,7 +96,6 @@ export const finishGithubLogin = async (req,res) => ...@@ -99,7 +96,6 @@ export const finishGithubLogin = async (req,res) =>
99 const params = new URLSearchParams(config).toString(); 96 const params = new URLSearchParams(config).toString();
100 const baseURL = `https://github.com/login/oauth/access_token`; 97 const baseURL = `https://github.com/login/oauth/access_token`;
101 const finalURL = `${baseURL}?${params}`; 98 const finalURL = `${baseURL}?${params}`;
102 - console.log(req.query);
103 const data = await fetch(finalURL,{ 99 const data = await fetch(finalURL,{
104 method:"POST", 100 method:"POST",
105 headers:{ 101 headers:{
......
1 import fetch from "node-fetch" 1 import fetch from "node-fetch"
2 2
3 -const getMovies = async ()=>{
4 - const BASEURL = `https://yts.mx/api/v2/list_movies.json`;
5 - const movies = await fetch(BASEURL,{
6 -
7 - });
8 - console.log(movies);
9 -}
10 -
11 -export const showMovies = (req,res) =>{
12 - //getMovies();
13 - res.send("movie home");
14 -}
15 3
16 export const movieInformation = async (req,res)=>{ 4 export const movieInformation = async (req,res)=>{
17 const {id}= req.params; 5 const {id}= req.params;
...@@ -27,7 +15,6 @@ export const getDiscover = (req, res)=>{ ...@@ -27,7 +15,6 @@ export const getDiscover = (req, res)=>{
27 15
28 export const postDiscover = async (req, res)=>{ 16 export const postDiscover = async (req, res)=>{
29 const {year, genre,rating} = req.body 17 const {year, genre,rating} = req.body
30 - console.log(year,genre,rating)
31 const KEY= process.env.API_KEY 18 const KEY= process.env.API_KEY
32 const genreData = await fetch(`https://api.themoviedb.org/3/genre/movie/list?api_key=${KEY}&language=en-US`) 19 const genreData = await fetch(`https://api.themoviedb.org/3/genre/movie/list?api_key=${KEY}&language=en-US`)
33 const genres = await genreData.json() 20 const genres = await genreData.json()
...@@ -35,7 +22,7 @@ export const postDiscover = async (req, res)=>{ ...@@ -35,7 +22,7 @@ export const postDiscover = async (req, res)=>{
35 const genreId = target[0].id 22 const genreId = target[0].id
36 23
37 const moviesData = await fetch(` 24 const moviesData = await fetch(`
38 - https://api.themoviedb.org/3/discover/movie?api_key=${KEY}&language=en-US&sort_by=popularity.desc&include_adult=false&include_video=false&page=1&year=${year}&vote_average.gte=${rating}&with_genres=28%2C12&with_watch_monetization_types=flatrate`, 25 + https://api.themoviedb.org/3/discover/movie?api_key=${KEY}&language=en-US&sort_by=popularity.desc&include_adult=false&include_video=false&page=1&year=${year}&vote_average.gte=${rating}&with_genres=${genreId}&with_watch_monetization_types=flatrate`,
39 { 26 {
40 method:"GET" 27 method:"GET"
41 }) 28 })
...@@ -43,4 +30,4 @@ export const postDiscover = async (req, res)=>{ ...@@ -43,4 +30,4 @@ export const postDiscover = async (req, res)=>{
43 const movies = Result.results 30 const movies = Result.results
44 console.log(movies) 31 console.log(movies)
45 return res.render(`discoverResult.pug`,{siteTitle:"movie!",movies}) 32 return res.render(`discoverResult.pug`,{siteTitle:"movie!",movies})
46 -} 33 +}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,7 +3,6 @@ import "./db" ...@@ -3,7 +3,6 @@ import "./db"
3 import "../models/User" 3 import "../models/User"
4 import app from "./server"; 4 import app from "./server";
5 5
6 -console.log("hihihihihih")
7 6
8 const PORT = 3000 7 const PORT = 3000
9 8
......
1 import express from "express"; 1 import express from "express";
2 -import { showMovies, movieInformation, getDiscover, postDiscover } from "../controllers/movieController"; 2 +import { movieInformation, getDiscover, postDiscover } from "../controllers/movieController";
3 3
4 const movieRouter = express.Router(); 4 const movieRouter = express.Router();
5 5
6 -movieRouter.get('/',showMovies);
7 -
8 movieRouter.get('/:id(\\d+)', movieInformation); 6 movieRouter.get('/:id(\\d+)', movieInformation);
9 7
10 movieRouter.route('/discover/').get(getDiscover).post(postDiscover) 8 movieRouter.route('/discover/').get(getDiscover).post(postDiscover)
......
1 extends layout.pug 1 extends layout.pug
2 -include mixins/trending.pug 2 +include mixins/movies.pug
3 3
4 block content 4 block content
5 div 5 div
......
1 extends layout.pug 1 extends layout.pug
2 -include mixins/trending.pug 2 +include mixins/movies.pug
3 3
4 block content 4 block content
5 div 5 div
6 h1=pageTitle 6 h1=pageTitle
7 small 이번주에 인기있는 영화들 7 small 이번주에 인기있는 영화들
8 - +trending(movies)
...\ No newline at end of file ...\ No newline at end of file
8 + +movies(movies)
...\ No newline at end of file ...\ No newline at end of file
......
1 -mixin trending(movies)
2 - div
3 - ul
4 - each movie in movies
5 - li
6 - a(href=`/movies/${movie.id}`)=movie.title
...\ No newline at end of file ...\ No newline at end of file
...@@ -4,7 +4,7 @@ header ...@@ -4,7 +4,7 @@ header
4 li 4 li
5 a(href="/") Home 5 a(href="/") Home
6 li 6 li
7 - a(href="/movies/discover/") Movies 7 + a(href="/movies/discover/") Search Movies
8 if loggedIn 8 if loggedIn
9 li 9 li
10 a(href="/logout") logout 10 a(href="/logout") logout
......