mirror of
https://github.com/sct/overseerr.git
synced 2025-12-26 00:16:16 +01: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:
@@ -5,6 +5,7 @@ import { checkUser, isAuthenticated } from '../middleware/auth';
|
||||
import settingsRoutes from './settings';
|
||||
import { Permission } from '../lib/permissions';
|
||||
import { getSettings } from '../lib/settings';
|
||||
import searchRoutes from './search';
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -15,6 +16,7 @@ router.use(
|
||||
isAuthenticated(Permission.MANAGE_SETTINGS),
|
||||
settingsRoutes
|
||||
);
|
||||
router.use('/search', isAuthenticated(), searchRoutes);
|
||||
router.use('/auth', authRoutes);
|
||||
|
||||
router.get('/settings/public', (_req, res) => {
|
||||
|
||||
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