This commit is contained in:
naskya 2024-06-20 07:31:09 +09:00
parent 2d4af8fdbb
commit 24691276a9
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
4 changed files with 31 additions and 12 deletions

1
Cargo.lock generated
View file

@ -425,7 +425,6 @@ dependencies = [
"clap",
"color-print",
"serde",
"serde_json",
"sqlx",
"thiserror",
"tokio",

View file

@ -10,7 +10,6 @@ clap = { version = "4.5", features = ["derive"] }
color-print = "0.3"
thiserror = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sqlx = { version = "0.7", features = ["runtime-tokio", "postgres"] }
tokio = { version = "1.38", features = ["full"] }
toml = "0.8"

View file

@ -10,11 +10,6 @@ use validator::{Validate, ValidationError};
#[derive(Deserialize, Serialize, Validate, Debug)]
pub struct Config {
appearance: Appearance,
}
#[derive(Deserialize, Serialize, Validate, Debug)]
pub struct Appearance {
/// Server-wide default light theme
light_theme: Option<String>,
/// Server-wide default light theme

View file

@ -8,21 +8,47 @@
use serde::{Deserialize, Serialize};
use validator::Validate;
type Port = u16;
#[derive(Deserialize, Serialize, Validate, Debug)]
pub struct Config {
info: Option<Info>,
timelines: Option<Timelines>,
network: Network,
database: Database,
cache_server: CacheServer,
id: Option<Id>,
}
#[derive(Deserialize, Serialize, Validate, Debug)]
pub struct Info {
/// Server name
name: Option<String>,
/// Server description
description: Option<String>,
/// Name/handle of the server maintainer
maintainer_name: Option<String>,
/// Contact info (e.g., email) of the server maintainer
contact_info: Option<String>,
/// Whether the server allows open self-registration
open_registrations: bool,
/// Repository URL
repository_url: Option<String>,
}
#[derive(Deserialize, Serialize, Validate, Debug)]
pub struct Timelines {
/// Whether to enable the local timeline
local: bool,
/// Whether to enable the global timeline
global: bool,
/// Whether to publish the local/global timelines to signed out users
guest: bool,
}
#[derive(Deserialize, Serialize, Validate, Debug)]
pub struct Network {
protocol: Option<HttpProtocol>,
host: String,
port: Port,
port: u16,
}
#[derive(Deserialize, Serialize, Debug)]
@ -34,7 +60,7 @@ pub enum HttpProtocol {
#[derive(Deserialize, Serialize, Validate, Debug)]
pub struct Database {
host: String,
port: Port,
port: u16,
user: String,
password: String,
name: String,
@ -43,7 +69,7 @@ pub struct Database {
#[derive(Deserialize, Serialize, Validate, Debug)]
pub struct CacheServer {
host: String,
port: Port,
port: u16,
user: Option<String>,
password: Option<String>,
index: Option<String>,