Only connect to Meili with valid config
This commit is contained in:
parent
69852b8a05
commit
e52b1330d3
@ -9,19 +9,20 @@ import { Followings, Users } from "@/models/index.js";
|
|||||||
|
|
||||||
const logger = dbLogger.createSubLogger("meilisearch", "gray", false);
|
const logger = dbLogger.createSubLogger("meilisearch", "gray", false);
|
||||||
|
|
||||||
logger.info("Connecting to MeiliSearch");
|
|
||||||
|
|
||||||
const hasConfig =
|
const hasConfig =
|
||||||
config.meilisearch &&
|
config.meilisearch &&
|
||||||
(config.meilisearch.host ||
|
(config.meilisearch.host ||
|
||||||
config.meilisearch.port ||
|
config.meilisearch.port ||
|
||||||
config.meilisearch.apiKey);
|
config.meilisearch.apiKey);
|
||||||
|
|
||||||
|
if (hasConfig) {
|
||||||
const host = hasConfig ? config.meilisearch.host ?? "localhost" : "";
|
const host = hasConfig ? config.meilisearch.host ?? "localhost" : "";
|
||||||
const port = hasConfig ? config.meilisearch.port ?? 7700 : 0;
|
const port = hasConfig ? config.meilisearch.port ?? 7700 : 0;
|
||||||
const auth = hasConfig ? config.meilisearch.apiKey ?? "" : "";
|
const auth = hasConfig ? config.meilisearch.apiKey ?? "" : "";
|
||||||
const ssl = hasConfig ? config.meilisearch.ssl ?? false : false;
|
const ssl = hasConfig ? config.meilisearch.ssl ?? false : false;
|
||||||
|
|
||||||
|
logger.info("Connecting to MeiliSearch");
|
||||||
|
|
||||||
const client: MeiliSearch = new MeiliSearch({
|
const client: MeiliSearch = new MeiliSearch({
|
||||||
host: `${ssl ? "https" : "http"}://${host}:${port}`,
|
host: `${ssl ? "https" : "http"}://${host}:${port}`,
|
||||||
apiKey: auth,
|
apiKey: auth,
|
||||||
@ -58,6 +59,7 @@ posts
|
|||||||
);
|
);
|
||||||
|
|
||||||
logger.info("Connected to MeiliSearch");
|
logger.info("Connected to MeiliSearch");
|
||||||
|
}
|
||||||
|
|
||||||
export type MeilisearchNote = {
|
export type MeilisearchNote = {
|
||||||
id: string;
|
id: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user