Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
fix: assert valid typesense config
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed Apr 30, 2024
1 parent 5773b30 commit cb5a4c8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/search/create-search-client.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { assert } from "@acdh-oeaw/lib";
import { Client } from "typesense";

import { env } from "@/config/env.config";

export function createSearchClient(apiKey = env.NEXT_PUBLIC_TYPESENSE_API_KEY) {
const host = env.NEXT_PUBLIC_TYPESENSE_HOST;
const port = env.NEXT_PUBLIC_TYPESENSE_PORT;
const protocol = env.NEXT_PUBLIC_TYPESENSE_PROTOCOL;

assert(apiKey, "Invalid typesense config.");
assert(host, "Invalid typesense config.");
assert(port, "Invalid typesense config.");
assert(protocol, "Invalid typesense config.");

const client = new Client({
nodes: [
{
host: env.NEXT_PUBLIC_TYPESENSE_HOST,
port: env.NEXT_PUBLIC_TYPESENSE_PORT,
protocol: env.NEXT_PUBLIC_TYPESENSE_PROTOCOL,
},
],
nodes: [{ host, port, protocol }],
apiKey,
});

Expand Down

0 comments on commit cb5a4c8

Please sign in to comment.