init: toloka

This commit is contained in:
ner committed 2024-10-25 22:00:02 +03:00
1 parent be9a128793
commit 345cf911a4
5 files changed
+48 -60

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import { NextRequest } from 'next/server';
import { Sort } from '@/api/parsers';
import pirateBay from '@/api/parsers/pirate-bay';
import toloka from '@/api/parsers/toloka';
import yts from '@/api/parsers/yts';
export async function GET({ nextUrl: { searchParams } }: NextRequest) {
const key = searchParams.get('key') as keyof typeof providers;
const imdbID = searchParams.get('imdbID') as string;
const query = searchParams.get('query') as string;
const sort = searchParams.get('sort') as Sort;
const providers = { yts: yts, tpb: pirateBay, tlk: toloka };
try {
return Response.json(await providers[key].search({ imdbID, query, sort }));
} catch (_) {
return Response.json([]);
}
}