mirror of
https://gitlab.com/foxixus/neomovies-api.git
synced 2025-10-28 01:48:51 +05:00
Delete /movies/search route
This commit is contained in:
@@ -13,98 +13,6 @@ router.use((req, res, next) => {
|
|||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* @swagger
|
|
||||||
* /movies/search:
|
|
||||||
* get:
|
|
||||||
* summary: Поиск фильмов
|
|
||||||
* description: Поиск фильмов по запросу с поддержкой русского языка
|
|
||||||
* tags: [movies]
|
|
||||||
* parameters:
|
|
||||||
* - in: query
|
|
||||||
* name: query
|
|
||||||
* required: true
|
|
||||||
* description: Поисковый запрос
|
|
||||||
* schema:
|
|
||||||
* type: string
|
|
||||||
* example: Матрица
|
|
||||||
* - in: query
|
|
||||||
* name: page
|
|
||||||
* description: Номер страницы (по умолчанию 1)
|
|
||||||
* schema:
|
|
||||||
* type: integer
|
|
||||||
* minimum: 1
|
|
||||||
* default: 1
|
|
||||||
* example: 1
|
|
||||||
* responses:
|
|
||||||
* 200:
|
|
||||||
* description: Успешный поиск
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* type: object
|
|
||||||
* properties:
|
|
||||||
* page:
|
|
||||||
* type: integer
|
|
||||||
* description: Текущая страница
|
|
||||||
* total_pages:
|
|
||||||
* type: integer
|
|
||||||
* description: Всего страниц
|
|
||||||
* total_results:
|
|
||||||
* type: integer
|
|
||||||
* description: Всего результатов
|
|
||||||
* results:
|
|
||||||
* type: array
|
|
||||||
* items:
|
|
||||||
* $ref: '#/components/schemas/Movie'
|
|
||||||
* 400:
|
|
||||||
* description: Неверный запрос
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: '#/components/schemas/Error'
|
|
||||||
* 500:
|
|
||||||
* description: Ошибка сервера
|
|
||||||
* content:
|
|
||||||
* application/json:
|
|
||||||
* schema:
|
|
||||||
* $ref: '#/components/schemas/Error'
|
|
||||||
*/
|
|
||||||
router.get('/search', async (req, res) => {
|
|
||||||
try {
|
|
||||||
const { query, page = 1 } = req.query;
|
|
||||||
|
|
||||||
if (!query) {
|
|
||||||
return res.status(400).json({ error: 'Query parameter is required' });
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Search request:', { query, page });
|
|
||||||
|
|
||||||
const data = await req.tmdb.searchMovies(query, page);
|
|
||||||
|
|
||||||
console.log('Search response:', {
|
|
||||||
page: data.page,
|
|
||||||
total_results: data.total_results,
|
|
||||||
total_pages: data.total_pages,
|
|
||||||
results_count: data.results?.length
|
|
||||||
});
|
|
||||||
|
|
||||||
// Форматируем даты в результатах
|
|
||||||
const formattedResults = data.results.map(movie => ({
|
|
||||||
...movie,
|
|
||||||
release_date: formatDate(movie.release_date)
|
|
||||||
}));
|
|
||||||
|
|
||||||
res.json({
|
|
||||||
...data,
|
|
||||||
results: formattedResults
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error searching movies:', error);
|
|
||||||
res.status(500).json({ error: error.message });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
* /search/multi:
|
* /search/multi:
|
||||||
|
|||||||
Reference in New Issue
Block a user