Commit 60d4bbf9 authored by Kim, Subin's avatar Kim, Subin
Browse files

server-movie

parent fdd2a316
import axios from "axios"; import axios from "axios";
import { baseUrl, TMDBUrl } from "../utils/baseUrl.js"; import { baseUrl, TMDBUrl } from "../utils/baseUrl.js";
const getAllfromTM = async () => { const getAllfromTM = async () => {
const payload = { const payload = {
params: { params: {
......
import axios from 'axios' import axios from 'axios'
import sequelize from 'sequelize';
const { Op } = sequelize
import { Movie } from '../db/index.js' import { Movie } from '../db/index.js'
import sequelize from 'sequelize'
const { Op } = sequelize
const getMovieByCategory = async (req, res, next, category) => { const getMovieByCategory = async (req, res, next, category) => {
try { try {
...@@ -96,8 +96,7 @@ const getAllMovie = async (req, res, next) => { ...@@ -96,8 +96,7 @@ const getAllMovie = async (req, res, next) => {
const { pageNum } = req.query const { pageNum } = req.query
const now = new Date() const now = new Date()
const monthAgo = new Date(now.setMonth(now.getMonth() - 1)).toJSON().split(/T/)[0] const monthAgo = new Date(now.setMonth(now.getMonth() - 1)).toJSON().split(/T/)[0]
// const response = await axios.get(`https://api.themoviedb.org/3/discover/movie?api_key=${process.env.TMDB_APP_KEY}&language=ko-KR&region=KR&sort_by=release_date.asc&release_date.gte=${monthAgo}&page=${pageNum}`) const response = await axios.get(`https://api.themoviedb.org/3/discover/movie?api_key=${process.env.TMDB_APP_KEY}&language=ko-KR&region=KR&sort_by=release_date.asc&release_date.gte=${monthAgo}&page=${pageNum}`)
const response = await axios.get(`https://api.themoviedb.org/3/discover/movie?api_key=${process.env.TMDB_APP_KEY}&language=ko-KR&region=KR&sort_by=release_date.asc&release_date.gte=${monthAgo}&page=6`)
req.TMDBmovies = response.data.results req.TMDBmovies = response.data.results
next() next()
} catch (error) { } catch (error) {
......
...@@ -15,7 +15,8 @@ router.route('/movielist') ...@@ -15,7 +15,8 @@ router.route('/movielist')
router router
.route("/all") .route("/all")
.get(movieCtrl.getAllMovie, .get(
movieCtrl.getAllMovie,
movieCtrl.movieforAdmin movieCtrl.movieforAdmin
) )
...@@ -25,7 +26,8 @@ router ...@@ -25,7 +26,8 @@ router
router router
.route("/search/admin") .route("/search/admin")
.get(movieCtrl.findaboutAll, .get(
movieCtrl.findaboutAll,
movieCtrl.movieforAdmin movieCtrl.movieforAdmin
) )
...@@ -35,4 +37,5 @@ router ...@@ -35,4 +37,5 @@ router
.delete(movieCtrl.remove) .delete(movieCtrl.remove)
router.param('category', movieCtrl.getMovieByCategory) router.param('category', movieCtrl.getMovieByCategory)
export default router; export default router;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment