server/utils/config.ts

41 lines
779 B
TypeScript
Raw Normal View History

2023-09-11 05:31:08 +02:00
import data from "../config/config.toml";
2023-09-11 05:46:20 +02:00
export interface ConfigType {
2023-09-11 05:31:08 +02:00
database: {
host: string;
port: number;
username: string;
password: string;
database: string;
2023-09-13 02:29:13 +02:00
};
2023-09-11 05:54:14 +02:00
http: {
port: number;
base_url: string;
2023-09-13 02:29:13 +02:00
};
2023-09-13 07:30:45 +02:00
validation: {
max_displayname_size: number;
max_bio_size: number;
max_username_size: number;
max_note_size: number;
max_media_size: number;
max_media_attachments: number;
max_media_description_size: number;
username_blacklist: string[];
blacklist_tempmail: boolean;
email_blacklist: string[];
url_scheme_whitelist: string[];
};
2023-09-13 02:29:13 +02:00
[key: string]: unknown;
2023-09-11 05:31:08 +02:00
}
export const getConfig = () => {
return data as ConfigType;
2023-09-13 02:29:13 +02:00
};
2023-09-11 05:54:14 +02:00
export const getHost = () => {
const url = new URL(getConfig().http.base_url);
return url.host;
2023-09-13 02:29:13 +02:00
};