You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
527 B
19 lines
527 B
4 years ago
|
import { Router } from 'express';
|
||
|
import TheMovieDb from '../api/themoviedb';
|
||
|
import { mapMovieDetails } from '../models/Movie';
|
||
|
import { MediaRequest } from '../entity/MediaRequest';
|
||
|
|
||
|
const movieRoutes = Router();
|
||
|
|
||
|
movieRoutes.get('/:id', async (req, res) => {
|
||
|
const tmdb = new TheMovieDb();
|
||
|
|
||
|
const movie = await tmdb.getMovie({ movieId: Number(req.params.id) });
|
||
|
|
||
|
const request = await MediaRequest.getRequest(movie.id);
|
||
|
|
||
|
return res.status(200).json(mapMovieDetails(movie, request));
|
||
|
});
|
||
|
|
||
|
export default movieRoutes;
|