refactor: ♻️ Replace Meilisearch with Sonic

This commit is contained in:
Jesse Wierzbinski 2024-06-28 23:40:44 -10:00
parent 2cf1537a7e
commit 19c15f7e96
No known key found for this signature in database
15 changed files with 338 additions and 211 deletions

View file

@ -76,7 +76,7 @@ export const configValidator = z.object({
enabled: false,
}),
}),
meilisearch: z.object({
sonic: z.object({
host: z.string().min(1).default("localhost"),
port: z
.number()
@ -84,7 +84,7 @@ export const configValidator = z.object({
.min(1)
.max(2 ** 16 - 1)
.default(7700),
api_key: z.string(),
password: z.string(),
enabled: z.boolean().default(false),
}),
signups: z.object({

View file

@ -1,7 +1,6 @@
import { idValidator } from "@/api";
import { getBestContentType, urlToContentFormat } from "@/content_types";
import { randomString } from "@/math";
import { addUserToMeilisearch } from "@/meilisearch";
import { proxyUrl } from "@/response";
import type {
Account as ApiAccount,
@ -31,6 +30,7 @@ import {
type UserWithRelations,
findManyUsers,
} from "~/classes/functions/user";
import { searchManager } from "~/classes/search/search-manager";
import { db } from "~/drizzle/db";
import {
EmojiToUser,
@ -294,8 +294,8 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
throw new Error("Failed to save user from remote");
}
// Add to Meilisearch
await addUserToMeilisearch(finalUser);
// Add to search index
await searchManager.addUser(finalUser);
return finalUser;
}
@ -477,8 +477,8 @@ export class User extends BaseInterface<typeof Users, UserWithRelations> {
throw new Error("Failed to create user");
}
// Add to Meilisearch
await addUserToMeilisearch(finalUser);
// Add to search index
await searchManager.addUser(finalUser);
return finalUser;
}