mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
refactor: ♻️ Replace Meilisearch with Sonic
This commit is contained in:
parent
2cf1537a7e
commit
19c15f7e96
15 changed files with 338 additions and 211 deletions
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue