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

server-movie

parent fdd2a316
import axios from "axios";
import { baseUrl, TMDBUrl } from "../utils/baseUrl.js";
const getAllfromTM = async () => {
const payload = {
params: {
......
import axios from 'axios'
import sequelize from 'sequelize';
const { Op } = sequelize
import { Movie } from '../db/index.js'
import sequelize from 'sequelize'
const { Op } = sequelize
const getMovieByCategory = async (req, res, next, category) => {
try {
......@@ -96,8 +96,7 @@ const getAllMovie = async (req, res, next) => {
const { pageNum } = req.query
const now = new Date()
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=6`)
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}`)
req.TMDBmovies = response.data.results
next()
} catch (error) {
......
......@@ -15,7 +15,8 @@ router.route('/movielist')
router
.route("/all")
.get(movieCtrl.getAllMovie,
.get(
movieCtrl.getAllMovie,
movieCtrl.movieforAdmin
)
......@@ -25,7 +26,8 @@ router
router
.route("/search/admin")
.get(movieCtrl.findaboutAll,
.get(
movieCtrl.findaboutAll,
movieCtrl.movieforAdmin
)
......@@ -35,4 +37,5 @@ router
.delete(movieCtrl.remove)
router.param('category', movieCtrl.getMovieByCategory)
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