mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(api): tmdb api wrapper / multi search route (#62)
Adds a "The Movie DB" api wrapper for some basic requests (search/get movie details/get tv details). Also adds a search endpoint to our api and mappers to convert the tmdb results
This commit is contained in:
21
server/routes/search.ts
Normal file
21
server/routes/search.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Router } from 'express';
|
||||
import TheMovieDb from '../api/themoviedb';
|
||||
import { mapSearchResults } from '../models/Search';
|
||||
|
||||
const searchRoutes = Router();
|
||||
|
||||
searchRoutes.get('/', async (req, res) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const results = await tmdb.searchMulti({ query: req.query.query as string });
|
||||
const megaResults = mapSearchResults(results.results);
|
||||
console.log(megaResults);
|
||||
return res.status(200).json({
|
||||
page: results.page,
|
||||
totalPages: results.total_pages,
|
||||
totalResults: results.total_results,
|
||||
results: mapSearchResults(results.results),
|
||||
});
|
||||
});
|
||||
|
||||
export default searchRoutes;
|
Reference in New Issue
Block a user