mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-22 01:47:39 -07:00
Merge pull request 'Only connect to Meili with valid config' (#10222) from PrivateGER/calckey:fix/meilisearch-fallback-code into develop
Reviewed-on: https://codeberg.org/calckey/calckey/pulls/10222
This commit is contained in:
commit
dc8b994679
1 changed files with 39 additions and 37 deletions
|
@ -9,19 +9,20 @@ import { Followings, Users } from "@/models/index.js";
|
|||
|
||||
const logger = dbLogger.createSubLogger("meilisearch", "gray", false);
|
||||
|
||||
logger.info("Connecting to MeiliSearch");
|
||||
|
||||
const hasConfig =
|
||||
config.meilisearch &&
|
||||
(config.meilisearch.host ||
|
||||
config.meilisearch.port ||
|
||||
config.meilisearch.apiKey);
|
||||
|
||||
if (hasConfig) {
|
||||
const host = hasConfig ? config.meilisearch.host ?? "localhost" : "";
|
||||
const port = hasConfig ? config.meilisearch.port ?? 7700 : 0;
|
||||
const auth = hasConfig ? config.meilisearch.apiKey ?? "" : "";
|
||||
const ssl = hasConfig ? config.meilisearch.ssl ?? false : false;
|
||||
|
||||
logger.info("Connecting to MeiliSearch");
|
||||
|
||||
const client: MeiliSearch = new MeiliSearch({
|
||||
host: `${ssl ? "https" : "http"}://${host}:${port}`,
|
||||
apiKey: auth,
|
||||
|
@ -58,6 +59,7 @@ posts
|
|||
);
|
||||
|
||||
logger.info("Connected to MeiliSearch");
|
||||
}
|
||||
|
||||
export type MeilisearchNote = {
|
||||
id: string;
|
||||
|
|
Loading…
Reference in a new issue