Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
added validation on every USE_DB_AUTHENTICATION call
rafaelsideguidebbed6ef23d32
diff --git a/apps/api/src/controllers/crawl-status.ts b/apps/api/src/controllers/crawl-status.tsindex 5aafa4333..82a49db81 100644--- a/apps/api/src/controllers/crawl-status.ts+++ b/apps/api/src/controllers/crawl-status.ts@@ -24,7 +24,8 @@ export async function crawlStatusController(req: Request, res: Response) {const { current, current_url, total, current_step, partialDocs } = await job.progress();let data = job.returnvalue;- if (process.env.USE_DB_AUTHENTICATION === "true") {+ const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';+ if (useDbAuthentication) {const supabaseData = await supabaseGetJobById(req.params.jobId);if (supabaseData) {diff --git a/apps/api/src/controllers/status.ts b/apps/api/src/controllers/status.tsindex 3d7fccbb0..935338bd0 100644--- a/apps/api/src/controllers/status.ts+++ b/apps/api/src/controllers/status.ts@@ -12,7 +12,8 @@ export async function crawlJobStatusPreviewController(req: Request, res: Responsconst { current, current_url, total, current_step, partialDocs } = await job.progress();let data = job.returnvalue;- if (process.env.USE_DB_AUTHENTICATION === "true") {+ const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';+ if (useDbAuthentication) {const supabaseData = await supabaseGetJobById(req.params.jobId);if (supabaseData) {diff --git a/apps/api/src/lib/logger.ts b/apps/api/src/lib/logger.tsindex 872dbf510..fb0468c2f 100644--- a/apps/api/src/lib/logger.ts+++ b/apps/api/src/lib/logger.ts@@ -25,7 +25,8 @@ export class Logger {const color = Logger.colors[level];console[level.toLowerCase()](color, `[${new Date().toISOString()}]${level} - ${message}`);- // if (process.env.USE_DB_AUTH) {+ // const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';+ // if (useDbAuthentication) {// save to supabase? another place?// supabase.from('logs').insert({ level: level, message: message, timestamp: new Date().toISOString(), success: boolean });// }diff --git a/apps/api/src/lib/scrape-events.ts b/apps/api/src/lib/scrape-events.tsindex 8d677279b..02ef670b8 100644--- a/apps/api/src/lib/scrape-events.ts+++ b/apps/api/src/lib/scrape-events.ts@@ -36,7 +36,8 @@ export class ScrapeEvents {static async insert(jobId: string, content: ScrapeEvent) {if (jobId === "TEST") return null;- if (process.env.USE_DB_AUTHENTICATION) {+ const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';+ if (useDbAuthentication) {try {const result = await supabase.from("scrape_events").insert({job_id: jobId,diff --git a/apps/api/src/lib/withAuth.ts b/apps/api/src/lib/withAuth.tsindex 353c144be..1979907ef 100644--- a/apps/api/src/lib/withAuth.ts+++ b/apps/api/src/lib/withAuth.ts@@ -7,7 +7,8 @@ export function withAuth<T extends AuthResponse, U extends any[]>(originalFunction: (...args: U) => Promise<T>) {return async function (...args: U): Promise<T> {- if (process.env.USE_DB_AUTHENTICATION === "false") {+ const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';+ if (!useDbAuthentication) {if (warningCount < 5) {Logger.warn("You're bypassing authentication");warningCount++;diff --git a/apps/api/src/main/runWebScraper.ts b/apps/api/src/main/runWebScraper.tsindex 76665aa25..3f3293b20 100644--- a/apps/api/src/main/runWebScraper.ts+++ b/apps/api/src/main/runWebScraper.ts@@ -123,7 +123,8 @@ export async function runWebScraper({const saveJob = async (job: Job, result: any) => {try {- if (process.env.USE_DB_AUTHENTICATION === "true") {+ const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';+ if (useDbAuthentication) {const { data, error } = await supabase_service.from("firecrawl_jobs").update({ docs: result })diff --git a/apps/api/src/services/logging/crawl_log.ts b/apps/api/src/services/logging/crawl_log.tsindex 68008e023..f19b02978 100644--- a/apps/api/src/services/logging/crawl_log.ts+++ b/apps/api/src/services/logging/crawl_log.ts@@ -3,7 +3,8 @@ import { Logger } from "../../../src/lib/logger";import "dotenv/config";export async function logCrawl(job_id: string, team_id: string) {- if (process.env.USE_DB_AUTHENTICATION === 'true') {+ const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';+ if (useDbAuthentication) {try {const { data, error } = await supabase_service.from("bulljobs_teams")diff --git a/apps/api/src/services/logging/log_job.ts b/apps/api/src/services/logging/log_job.tsindex 93d0b311b..2525917cd 100644--- a/apps/api/src/services/logging/log_job.ts+++ b/apps/api/src/services/logging/log_job.ts@@ -7,7 +7,8 @@ import { Logger } from "../../lib/logger";export async function logJob(job: FirecrawlJob) {try {- if (process.env.USE_DB_AUTHENTICATION === "false") {+ const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';+ if (!useDbAuthentication) {return;}diff --git a/apps/api/src/services/logging/scrape_log.ts b/apps/api/src/services/logging/scrape_log.tsindex 099e4a0b7..30d8fd1ee 100644--- a/apps/api/src/services/logging/scrape_log.ts+++ b/apps/api/src/services/logging/scrape_log.ts@@ -8,7 +8,8 @@ export async function logScrape(scrapeLog: ScrapeLog,pageOptions?: PageOptions) {- if (process.env.USE_DB_AUTHENTICATION === "false") {+ const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';+ if (!useDbAuthentication) {Logger.debug("Skipping logging scrape to Supabase");return;}diff --git a/apps/api/src/services/supabase.ts b/apps/api/src/services/supabase.tsindex 70ada12be..414d19251 100644--- a/apps/api/src/services/supabase.ts+++ b/apps/api/src/services/supabase.ts@@ -8,8 +8,9 @@ class SupabaseService {constructor() {const supabaseUrl = process.env.SUPABASE_URL;const supabaseServiceToken = process.env.SUPABASE_SERVICE_TOKEN;+ const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';// Only initialize the Supabase client if both URL and Service Token are provided.- if (process.env.USE_DB_AUTHENTICATION === "false") {+ if (!useDbAuthentication) {// Warn the user that Authentication is disabled by setting the client to nullLogger.warn("Authentication is disabled. Supabase client will not be initialized."diff --git a/apps/test-suite/utils/supabase.ts b/apps/test-suite/utils/supabase.tsindex abf7fd78c..3e66a9912 100644--- a/apps/test-suite/utils/supabase.ts+++ b/apps/test-suite/utils/supabase.ts@@ -9,7 +9,8 @@ class SupabaseService {const supabaseUrl = process.env.SUPABASE_URL;const supabaseServiceToken = process.env.SUPABASE_SERVICE_TOKEN;// Only initialize the Supabase client if both URL and Service Token are provided.- if (process.env.USE_DB_AUTHENTICATION === "false") {+ const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';+ if (!useDbAuthentication) {// Warn the user that Authentication is disabled by setting the client to nullconsole.warn("Authentication is disabled. Supabase client will not be initialized."@@ -36,7 +37,8 @@ export const supabase_service: SupabaseClient = new Proxy(new SupabaseService(),{get: function (target, prop, receiver) {- if (process.env.USE_DB_AUTHENTICATION === "false") {+ const useDbAuthentication = process.env.USE_DB_AUTHENTICATION === 'true';+ if (!useDbAuthentication) {console.debug("Attempted to access Supabase client when it's not configured.");