mirror of
https://github.com/movie-web/providers-api.git
synced 2025-09-13 07:53:27 +00:00
Move fetcher + providers inside request and localise eventId to write method
This commit is contained in:
16
src/index.ts
16
src/index.ts
@@ -11,15 +11,8 @@ import { mediaSchema } from '@/schema';
|
||||
import { validateTurnstile } from '@/turnstile';
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
let eventId = 0;
|
||||
|
||||
const fetcher = makeStandardFetcher(fetch);
|
||||
|
||||
const providers = makeProviders({
|
||||
fetcher,
|
||||
target: targets.NATIVE,
|
||||
});
|
||||
|
||||
async function writeSSEEvent(
|
||||
stream: Parameters<Parameters<typeof streamSSE>['1']>['0'],
|
||||
event: string,
|
||||
@@ -62,6 +55,13 @@ app.get('/scrape', async (context) => {
|
||||
return context.text('An error has occurred!');
|
||||
}
|
||||
|
||||
const fetcher = makeStandardFetcher(fetch);
|
||||
|
||||
const providers = makeProviders({
|
||||
fetcher,
|
||||
target: targets.NATIVE,
|
||||
});
|
||||
|
||||
return streamSSE(context, async (stream) => {
|
||||
const output = await providers.runAll({
|
||||
media,
|
||||
|
Reference in New Issue
Block a user