Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
mogery committed Feb 20, 2025
1 parent 94cabda commit 7bac95e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions apps/api/src/search/searxng.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import axios from "axios";
import dotenv from "dotenv";
import { SearchResult } from "../../src/lib/entities";
import { logger } from "../lib/logger"

dotenv.config();

Expand Down Expand Up @@ -30,10 +31,7 @@ export async function searxng_search(
format: "json"
};

const url = process.env.SEARXNG_ENDPOINT as string;
if (!url) {
console.error(`SEARXNG_ENDPOINT environment variable is not set`);
}
const url = process.env.SEARXNG_ENDPOINT!;
// Remove trailing slash if it exists
const cleanedUrl = url.endsWith('/') ? url.slice(0, -1) : url;

Expand All @@ -60,7 +58,7 @@ export async function searxng_search(
return [];
}
} catch (error) {
console.error(`There was an error searching for content: ${error.message}`);
logger.error(`There was an error searching for content`, { error });
return [];
}
}

0 comments on commit 7bac95e

Please sign in to comment.