refactoring: server actions data fetching -> api routes
This commit is contained in:
1 parent
1111712d2c
commit
5cbf93b3b8
38 files changed
+326
-308
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { createUniqueRandomGenerator } from '@/lib/utils';
|
||||
import movieAdvisor from '../clients/movieAdvisor';
|
||||
import mapMoviesSeriesResponseToShows from '../dto/Show';
|
||||
|
||||
const TOTAL_PAGES = 400;
|
||||
|
||||
export const generatePage = createUniqueRandomGenerator(TOTAL_PAGES);
|
||||
|
||||
const randomQuery = () => ({
|
||||
suspense: true,
|
||||
queryKey: ['random-movie'],
|
||||
initialPageParam: '1',
|
||||
queryFn: () =>
|
||||
movieAdvisor
|
||||
.get<TMDBPagination<Movie>>('/discover/movie', {
|
||||
params: {
|
||||
'vote_count.gte': 300,
|
||||
sort_by: 'popularity.desc',
|
||||
with_origin_country: 'UA|GB|JP|AU|US|IT|DE|FR',
|
||||
page: generatePage()
|
||||
}
|
||||
})
|
||||
.then(mapMoviesSeriesResponseToShows)
|
||||
});
|
||||
|
||||
export default randomQuery;
|
||||
Reference in new issue
Block a user