Merge branch 'develop' of codeberg.org:calckey/calckey into develop
This commit is contained in:
commit
ded157a9e5
|
@ -9,33 +9,34 @@ 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);
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
const client: MeiliSearch = new MeiliSearch({
|
||||
logger.info("Connecting to MeiliSearch");
|
||||
|
||||
const client: MeiliSearch = new MeiliSearch({
|
||||
host: `${ssl ? "https" : "http"}://${host}:${port}`,
|
||||
apiKey: auth,
|
||||
});
|
||||
});
|
||||
|
||||
const posts = client.index("posts");
|
||||
const posts = client.index("posts");
|
||||
|
||||
posts
|
||||
posts
|
||||
.updateSearchableAttributes(["text"])
|
||||
.catch((e) =>
|
||||
logger.error(`Setting searchable attr failed, searches won't work: ${e}`),
|
||||
);
|
||||
|
||||
posts
|
||||
posts
|
||||
.updateFilterableAttributes([
|
||||
"userName",
|
||||
"userHost",
|
||||
|
@ -49,7 +50,7 @@ posts
|
|||
),
|
||||
);
|
||||
|
||||
posts
|
||||
posts
|
||||
.updateSortableAttributes(["createdAt"])
|
||||
.catch((e) =>
|
||||
logger.error(
|
||||
|
@ -57,7 +58,8 @@ posts
|
|||
),
|
||||
);
|
||||
|
||||
logger.info("Connected to MeiliSearch");
|
||||
logger.info("Connected to MeiliSearch");
|
||||
}
|
||||
|
||||
export type MeilisearchNote = {
|
||||
id: string;
|
||||
|
|
Loading…
Reference in New Issue