mirror of
https://github.com/movie-web/providers-api.git
synced 2025-09-13 09:43:26 +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';
|
import { validateTurnstile } from '@/turnstile';
|
||||||
|
|
||||||
const app = new Hono();
|
const app = new Hono();
|
||||||
|
|
||||||
let eventId = 0;
|
let eventId = 0;
|
||||||
|
|
||||||
const fetcher = makeStandardFetcher(fetch);
|
|
||||||
|
|
||||||
const providers = makeProviders({
|
|
||||||
fetcher,
|
|
||||||
target: targets.NATIVE,
|
|
||||||
});
|
|
||||||
|
|
||||||
async function writeSSEEvent(
|
async function writeSSEEvent(
|
||||||
stream: Parameters<Parameters<typeof streamSSE>['1']>['0'],
|
stream: Parameters<Parameters<typeof streamSSE>['1']>['0'],
|
||||||
event: string,
|
event: string,
|
||||||
@@ -62,6 +55,13 @@ app.get('/scrape', async (context) => {
|
|||||||
return context.text('An error has occurred!');
|
return context.text('An error has occurred!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fetcher = makeStandardFetcher(fetch);
|
||||||
|
|
||||||
|
const providers = makeProviders({
|
||||||
|
fetcher,
|
||||||
|
target: targets.NATIVE,
|
||||||
|
});
|
||||||
|
|
||||||
return streamSSE(context, async (stream) => {
|
return streamSSE(context, async (stream) => {
|
||||||
const output = await providers.runAll({
|
const output = await providers.runAll({
|
||||||
media,
|
media,
|
||||||
|
Reference in New Issue
Block a user