mirror of
https://github.com/movie-web/providers-api.git
synced 2025-09-13 18:13:27 +00:00
Fix Turnstile enabled, remove TODO and log, add warning to readme
This commit is contained in:
18
src/index.ts
18
src/index.ts
@@ -1,4 +1,4 @@
|
||||
import { Hono } from 'hono';
|
||||
import { Context, Env, Hono } from 'hono';
|
||||
import { streamSSE } from 'hono/streaming';
|
||||
import { cors } from 'hono/cors';
|
||||
import {
|
||||
@@ -23,6 +23,10 @@ const providers = makeProviders({
|
||||
|
||||
const app = new Hono();
|
||||
|
||||
function isTurnstileEnabled(context: Context<Env>) {
|
||||
return (context.env?.TURNSTILE_ENABLED ?? "true") === "true"
|
||||
}
|
||||
|
||||
app.use('*', (context, next) => {
|
||||
const allowedCorsHosts = ((context.env?.CORS_ALLOWED as string) ?? '').split(
|
||||
',',
|
||||
@@ -60,11 +64,9 @@ async function writeSSEEvent(
|
||||
app.get('/scrape', async (context) => {
|
||||
const queryParams = context.req.query();
|
||||
|
||||
const turnstileEnabled = Boolean(context.env?.TURNSTILE_ENABLED);
|
||||
|
||||
let jwtResponse: string | undefined = undefined;
|
||||
|
||||
if (turnstileEnabled) {
|
||||
if (isTurnstileEnabled(context)) {
|
||||
const turnstileResponse = await validateTurnstile(context);
|
||||
|
||||
if (!turnstileResponse.success) {
|
||||
@@ -136,11 +138,9 @@ app.get('/scrape', async (context) => {
|
||||
app.get('/scrape/embed', async (context) => {
|
||||
const queryParams = context.req.query();
|
||||
|
||||
const turnstileEnabled = Boolean(context.env?.TURNSTILE_ENABLED);
|
||||
|
||||
let jwtResponse: string | undefined = undefined;
|
||||
|
||||
if (turnstileEnabled) {
|
||||
if (isTurnstileEnabled(context)) {
|
||||
const turnstileResponse = await validateTurnstile(context);
|
||||
|
||||
if (!turnstileResponse.success) {
|
||||
@@ -203,11 +203,9 @@ app.get('/scrape/embed', async (context) => {
|
||||
app.get('/scrape/source', async (context) => {
|
||||
const queryParams = context.req.query();
|
||||
|
||||
const turnstileEnabled = Boolean(context.env?.TURNSTILE_ENABLED);
|
||||
|
||||
let jwtResponse: string | undefined = undefined;
|
||||
|
||||
if (turnstileEnabled) {
|
||||
if (isTurnstileEnabled(context)) {
|
||||
const turnstileResponse = await validateTurnstile(context);
|
||||
|
||||
if (!turnstileResponse.success) {
|
||||
|
Reference in New Issue
Block a user