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
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
:
{
...
...
server/controllers/movie.controller.js
View file @
60d4bbf9
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®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=
${
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`
)
req
.
TMDBmovies
=
response
.
data
.
results
req
.
TMDBmovies
=
response
.
data
.
results
next
()
next
()
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
server/routes/movie.route.js
View file @
60d4bbf9
...
@@ -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
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