fix: response type

This commit is contained in:
ner committed 2024-10-25 22:04:06 +03:00
1 parent 345cf911a4
commit 5e9e7cb6a8
4 files changed
+4 -64

No files matched your search

+3 -3
View File
@@ -1,4 +1,4 @@
import { NextRequest } from 'next/server'; import { NextRequest, NextResponse } from 'next/server';
import { Sort } from '@/api/parsers'; import { Sort } from '@/api/parsers';
import pirateBay from '@/api/parsers/pirate-bay'; import pirateBay from '@/api/parsers/pirate-bay';
@@ -14,8 +14,8 @@ export async function GET({ nextUrl: { searchParams } }: NextRequest) {
const providers = { yts: yts, tpb: pirateBay, tlk: toloka }; const providers = { yts: yts, tpb: pirateBay, tlk: toloka };
try { try {
return Response.json(await providers[key].search({ imdbID, query, sort })); return NextResponse.json(await providers[key].search({ imdbID, query, sort }));
} catch (_) { } catch (_) {
return Response.json([]); return NextResponse.json([]);
} }
} }
@@ -1,39 +0,0 @@
'use client';
import { ReactNode } from 'react';
import { create, InstanceProps } from 'react-modal-promise';
import { Modal } from '@/components/ui/dialog';
import useTrailer from './useTrailer';
interface Props {
showId: Show['id'];
showType?: Show['type'];
children: ({ onPlay, disabled }: { onPlay: () => void; disabled: boolean }) => ReactNode;
}
const showTrailerModal = create(({ trailerKey, onResolve }: { trailerKey?: string } & InstanceProps<void>) => {
if (!trailerKey) return;
return (
<Modal className='block max-w-[930px] border-none bg-black p-0' style={{ aspectRatio: '16/9' }} onClose={onResolve}>
<iframe
allowFullScreen
allow='autoplay'
className='rounded-lg border-none'
width='100%'
height='100%'
src={`//www.youtube.com/embed/${trailerKey}?autoplay=1`}
/>
</Modal>
);
});
const ToggleTrailer = ({ showId, showType = 'movie', children }: Props) => {
const { data: trailer, isFetched } = useTrailer({ showId, showType });
return children({ onPlay: () => showTrailerModal({ trailerKey: trailer?.key }), disabled: isFetched && !trailer });
};
export default ToggleTrailer;
@@ -1,21 +0,0 @@
import { useQuery } from '@tanstack/react-query';
import { trailers } from '@/api';
interface Props {
showId: Show['id'];
showType: Show['type'];
}
const useTrailer = ({ showId, showType = 'movie' }: Props) =>
useQuery({
enabled: Boolean(showId),
queryKey: ['trailers', showId, showType],
queryFn: () => trailers({ showId, showType }),
select(trailers) {
const trailer = trailers[0];
return trailer?.site === 'YouTube' ? trailer : null;
}
});
export default useTrailer;
+1 -1
View File
@@ -1 +1 @@
if(!self.define){let e,s={};const a=(a,n)=>(a=new URL(a+".js",n).href,s[a]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=a,e.onload=s,document.head.appendChild(e)}else e=a,importScripts(a),s()})).then((()=>{let e=s[a];if(!e)throw new Error(`Module ${a} didn’t register its module`);return e})));self.define=(n,i)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let c={};const r=e=>a(e,t),o={module:{uri:t},exports:c,require:r};s[t]=Promise.all(n.map((e=>o[e]||r(e)))).then((e=>(i(...e),c)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"1df7667facd62f5f4fa582d1ba88c5cb"},{url:"/_next/static/EWvUMAZar8b7EDkgXgAVh/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/EWvUMAZar8b7EDkgXgAVh/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/152.e619d8b05424829e.js",revision:"e619d8b05424829e"},{url:"/_next/static/chunks/23-e95fe3862375276d.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/311-217b9962adac0d58.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/37-f6e2aef0dac1a9f4.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.a16beaad36f500fe.js",revision:"a16beaad36f500fe"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/693-2767062d917b3456.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/957-9f7dee59febd35c3.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/favorites/page-597921ef02c719df.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/loading-96645736797edde7.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/page-50279285390a6523.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/popular/page-b24c2917fc8bafde.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/similar/page-76c09599bd10ea14.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/starring/page-cddd4e2d83614eda.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/top/page-489f98dd6cd2a463.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/(site)/watch-list/page-e3f529e210a2a8e9.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/_not-found/page-aa0c8e90320336c2.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/app/layout-e78d8a67bc5fd6ae.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-bdf7d185613ab264.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/main-af50ab4bffe3e017.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-d4343f8c473d689d.js",revision:"EWvUMAZar8b7EDkgXgAVh"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/css/af880b2e4df9cb52.css",revision:"af880b2e4df9cb52"},{url:"/_next/static/media/46c21389e888bf13-s.woff2",revision:"272930c09ba14c81bb294be1fe18b049"},{url:"/_next/static/media/8888a3826f4a3af4-s.p.woff2",revision:"792477d09826b11d1e5a611162c9797a"},{url:"/_next/static/media/eafabf029ad39a43-s.p.woff2",revision:"43751174b6b810eb169101a20d8c26f8"},{url:"/_next/static/media/f5767adec246cdc1-s.woLine truncated if(!self.define){let e,s={};const n=(n,a)=>(n=new URL(n+".js",a).href,s[n]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()})).then((()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e})));self.define=(a,i)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let c={};const r=e=>n(e,t),o={module:{uri:t},exports:c,require:r};s[t]=Promise.all(a.map((e=>o[e]||r(e)))).then((e=>(i(...e),c)))}}define(["./workbox-4754cb34"],(function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"cc820509a568f1ed0928f084d3dab4e3"},{url:"/_next/static/Rmq9ZmYTV4UXCDEjS1N3T/_buildManifest.js",revision:"2ec694eb52ae4f523f265a46bae4d768"},{url:"/_next/static/Rmq9ZmYTV4UXCDEjS1N3T/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/152.e619d8b05424829e.js",revision:"e619d8b05424829e"},{url:"/_next/static/chunks/23-e95fe3862375276d.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/26.286553a5ff2812fc.js",revision:"286553a5ff2812fc"},{url:"/_next/static/chunks/276.c3c1130f2adade69.js",revision:"c3c1130f2adade69"},{url:"/_next/static/chunks/311-94835cadacd3eb37.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/344.05938a041227e582.js",revision:"05938a041227e582"},{url:"/_next/static/chunks/37-f6e2aef0dac1a9f4.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/383.78d47f7582340f53.js",revision:"78d47f7582340f53"},{url:"/_next/static/chunks/460.ac20021c7496f1d6.js",revision:"ac20021c7496f1d6"},{url:"/_next/static/chunks/497.a16beaad36f500fe.js",revision:"a16beaad36f500fe"},{url:"/_next/static/chunks/61.e269d4a699fba0b6.js",revision:"e269d4a699fba0b6"},{url:"/_next/static/chunks/621-fa4d2ff1cf645813.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/673.362c29137dd3e968.js",revision:"362c29137dd3e968"},{url:"/_next/static/chunks/693-2767062d917b3456.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/695.156d21364de6e419.js",revision:"156d21364de6e419"},{url:"/_next/static/chunks/755.5cd959eac5682527.js",revision:"5cd959eac5682527"},{url:"/_next/static/chunks/792.b51012549074b93f.js",revision:"b51012549074b93f"},{url:"/_next/static/chunks/810.6105e84414768b0d.js",revision:"6105e84414768b0d"},{url:"/_next/static/chunks/922.9ce4bf0553cfb724.js",revision:"9ce4bf0553cfb724"},{url:"/_next/static/chunks/957-9f7dee59febd35c3.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/app/(site)/favorites/page-597921ef02c719df.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/app/(site)/loading-96645736797edde7.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/app/(site)/page-892fa4f5465ef740.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/app/(site)/popular/page-b702f4ec7f04f753.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/app/(site)/similar/page-8d6944eecd2e9c66.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/app/(site)/starring/page-24a06769f34865b3.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/app/(site)/top/page-bccc8c4d6b946176.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/app/(site)/watch-list/page-e3f529e210a2a8e9.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/app/_not-found/page-aa0c8e90320336c2.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/app/layout-6b9a018d3f0990aa.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/c8bcbd21.63daf74955ffea8b.js",revision:"63daf74955ffea8b"},{url:"/_next/static/chunks/fd9d1056-bdf7d185613ab264.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/framework-f66176bb897dc684.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/main-65cc2be174f92f9a.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/main-app-51cdaff1a81e6b49.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/pages/_app-6a626577ffa902a4.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/pages/_error-1be831200e60c5c0.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-522f7df141f474e5.js",revision:"Rmq9ZmYTV4UXCDEjS1N3T"},{url:"/_next/static/css/0d5f6452b2682b9b.css",revision:"0d5f6452b2682b9b"},{url:"/_next/static/css/af880b2e4df9cb52.css",revision:"af880b2e4df9cb52"},{url:"/_next/static/media/46c21389e888bf13-s.woff2",revision:"272930c09ba14c81bb294be1fe18b049"},{url:"/_next/static/media/8888a3826f4a3af4-s.p.woff2",revision:"792477d09826b11d1e5a611162c9797a"},{url:"/_next/static/media/eafabf029ad39a43-s.p.woff2",revision:"43751174b6b810eb169101a20d8c26f8"},{url:"/_next/static/media/f5767adec246cdc1-s.woLine truncated