mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Update all packages, fix critical bugs
This commit is contained in:
parent
d85fe9efb6
commit
64629754ca
15 changed files with 48217 additions and 113 deletions
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
import { parse, stringify } from "@iarna/toml";
|
||||
import { deepMerge, deepMergeArray } from "@merge";
|
||||
import chalk from "chalk";
|
||||
import merge from "merge-deep-ts";
|
||||
|
||||
const scanConfig = async () => {
|
||||
const config = Bun.file(process.cwd() + "/config/config.toml");
|
||||
|
|
@ -92,6 +92,7 @@ export interface ConfigType {
|
|||
bind: string;
|
||||
bind_port: string;
|
||||
banned_ips: string[];
|
||||
banned_user_agents: string[];
|
||||
};
|
||||
|
||||
instance: {
|
||||
|
|
@ -215,6 +216,7 @@ export const configDefaults: ConfigType = {
|
|||
bind_port: "8000",
|
||||
base_url: "http://lysand.localhost:8000",
|
||||
banned_ips: [],
|
||||
banned_user_agents: [],
|
||||
},
|
||||
database: {
|
||||
host: "localhost",
|
||||
|
|
@ -398,11 +400,7 @@ export const configDefaults: ConfigType = {
|
|||
|
||||
export const getConfig = () => {
|
||||
// Deeply merge configDefaults, config and internalConfig
|
||||
return deepMergeArray([
|
||||
configDefaults,
|
||||
config,
|
||||
internalConfig,
|
||||
]) as any as ConfigType;
|
||||
return merge([configDefaults, config, internalConfig]) as any as ConfigType;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -410,13 +408,16 @@ export const getConfig = () => {
|
|||
* @param newConfig Any part of ConfigType
|
||||
*/
|
||||
export const setConfig = async (newConfig: Partial<ConfigType>) => {
|
||||
const newInternalConfig = deepMerge(internalConfig, newConfig);
|
||||
const newInternalConfig = merge([
|
||||
internalConfig,
|
||||
newConfig,
|
||||
]) as any as ConfigType;
|
||||
|
||||
// Prepend a warning comment and write the new TOML to the file
|
||||
await Bun.write(
|
||||
Bun.file(process.cwd() + "/config/config.internal.toml"),
|
||||
`# This file is automatically generated. Do not modify it manually.\n${stringify(
|
||||
newInternalConfig
|
||||
newInternalConfig as any
|
||||
)}`
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue