mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Replace config manager with unjs/c12
This commit is contained in:
parent
6b2e4044b6
commit
6a54c5b805
30 changed files with 744 additions and 733 deletions
|
|
@ -1,8 +1,6 @@
|
|||
// import { Queue } from "bullmq";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
import { ConfigManager } from "config-manager";
|
||||
|
||||
const config = await new ConfigManager({}).getConfig();
|
||||
import { config } from "config-manager";
|
||||
|
||||
const client = new PrismaClient({
|
||||
datasourceUrl: `postgresql://${config.database.username}:${config.database.password}@${config.database.host}:${config.database.port}/${config.database.database}`,
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ import type { Like } from "@prisma/client";
|
|||
import { client } from "~database/datasource";
|
||||
import type { UserWithRelations } from "./User";
|
||||
import type { StatusWithRelations } from "./Status";
|
||||
import { ConfigManager } from "config-manager";
|
||||
|
||||
const config = await new ConfigManager({}).getConfig();
|
||||
import { config } from "config-manager";
|
||||
|
||||
/**
|
||||
* Represents a Like entity in the database.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
// import { Worker } from "bullmq";
|
||||
import { statusToLysand, type StatusWithRelations } from "./Status";
|
||||
import type { User } from "@prisma/client";
|
||||
import { ConfigManager } from "config-manager";
|
||||
|
||||
const config = await new ConfigManager({}).getConfig();
|
||||
import { config } from "config-manager";
|
||||
|
||||
/* export const federationWorker = new Worker(
|
||||
"federation",
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@ import { parse } from "marked";
|
|||
import linkifyStr from "linkify-string";
|
||||
import linkifyHtml from "linkify-html";
|
||||
import { addStausToMeilisearch } from "@meilisearch";
|
||||
import { ConfigManager } from "config-manager";
|
||||
import { config } from "config-manager";
|
||||
import { statusAndUserRelations, userRelations } from "./relations";
|
||||
|
||||
const config = await new ConfigManager({}).getConfig();
|
||||
|
||||
const statusRelations = Prisma.validator<Prisma.StatusDefaultArgs>()({
|
||||
include: statusAndUserRelations,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { APIAccount } from "~types/entities/account";
|
||||
import type { LysandUser as LysandUser } from "~types/lysand/Object";
|
||||
import type { LysandUser } from "~types/lysand/Object";
|
||||
import { htmlToText } from "html-to-text";
|
||||
import type { User } from "@prisma/client";
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
|
@ -8,13 +8,10 @@ import { addEmojiIfNotExists, emojiToAPI, emojiToLysand } from "./Emoji";
|
|||
import { addInstanceIfNotExists } from "./Instance";
|
||||
import type { APISource } from "~types/entities/source";
|
||||
import { addUserToMeilisearch } from "@meilisearch";
|
||||
import { ConfigManager, type ConfigType } from "config-manager";
|
||||
import { config, type Config } from "config-manager";
|
||||
import { userRelations } from "./relations";
|
||||
import { MediaBackendType } from "~packages/media-manager";
|
||||
|
||||
const configManager = new ConfigManager({});
|
||||
const config = await configManager.getConfig();
|
||||
|
||||
export interface AuthData {
|
||||
user: UserWithRelations | null;
|
||||
token: string;
|
||||
|
|
@ -36,7 +33,7 @@ export type UserWithRelations = Prisma.UserGetPayload<typeof userRelations2>;
|
|||
* @param config The config to use
|
||||
* @returns The raw URL for the user's avatar
|
||||
*/
|
||||
export const getAvatarUrl = (user: User, config: ConfigType) => {
|
||||
export const getAvatarUrl = (user: User, config: Config) => {
|
||||
if (!user.avatar) return config.defaults.avatar;
|
||||
if (config.media.backend === MediaBackendType.LOCAL) {
|
||||
return `${config.http.base_url}/media/${user.avatar}`;
|
||||
|
|
@ -52,7 +49,7 @@ export const getAvatarUrl = (user: User, config: ConfigType) => {
|
|||
* @param config The config to use
|
||||
* @returns The raw URL for the user's header
|
||||
*/
|
||||
export const getHeaderUrl = (user: User, config: ConfigType) => {
|
||||
export const getHeaderUrl = (user: User, config: Config) => {
|
||||
if (!user.header) return config.defaults.header;
|
||||
if (config.media.backend === MediaBackendType.LOCAL) {
|
||||
return `${config.http.base_url}/media/${user.header}`;
|
||||
|
|
@ -192,8 +189,6 @@ export const createNewLocalUser = async (data: {
|
|||
header?: string;
|
||||
admin?: boolean;
|
||||
}) => {
|
||||
const config = await configManager.getConfig();
|
||||
|
||||
const keys = await generateUserKeys();
|
||||
|
||||
const user = await client.user.create({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue