Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
butter-studio
Commits
60d4bbf9
Commit
60d4bbf9
authored
Jul 24, 2021
by
Kim, Subin
Browse files
server-movie
parent
fdd2a316
Changes
3
Hide whitespace changes
Inline
Side-by-side
client/src/apis/movie.api.js
View file @
60d4bbf9
import
axios
from
"
axios
"
;
import
{
baseUrl
,
TMDBUrl
}
from
"
../utils/baseUrl.js
"
;
const
getAllfromTM
=
async
()
=>
{
const
payload
=
{
params
:
{
...
...
server/controllers/movie.controller.js
View file @
60d4bbf9
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®ion=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®ion=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®ion=KR&sort_by=release_date.asc&release_date.gte=
${
monthAgo
}
&page=
${
pageNum
}
`
)
req
.
TMDBmovies
=
response
.
data
.
results
next
()
}
catch
(
error
)
{
...
...
server/routes/movie.route.js
View file @
60d4bbf9
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment