Add YAML config loading with validation, env overrides for secrets, and a web dashboard exposing health, stats, and recent events.
64 lines
1.1 KiB
V
64 lines
1.1 KiB
V
module main
|
|
|
|
import sources
|
|
|
|
fn test_validate_minimal_config() {
|
|
cfg := Config{
|
|
server: ServerConfig{
|
|
url: 'https://ntfy.example.com'
|
|
listen: ':9090'
|
|
}
|
|
defaults: DefaultConfig{
|
|
priority: 3
|
|
tags: ['loudspeaker']
|
|
}
|
|
sources: SourcesConfig{
|
|
generic: [
|
|
sources.GenericSource{
|
|
name: 'test'
|
|
webhook_path: '/webhooks/test'
|
|
topic: 'test'
|
|
},
|
|
]
|
|
}
|
|
dedup: DedupConfig{
|
|
enabled: true
|
|
ttl_seconds: 300
|
|
rate_limit: RateLimitConfig{
|
|
max_per_minute: 10
|
|
max_per_source: 30
|
|
}
|
|
}
|
|
}
|
|
validate_config(cfg) or { panic(err) }
|
|
}
|
|
|
|
fn test_validate_missing_url() {
|
|
cfg := Config{
|
|
server: ServerConfig{
|
|
listen: ':9090'
|
|
}
|
|
defaults: DefaultConfig{
|
|
priority: 3
|
|
}
|
|
}
|
|
if _ := validate_config(cfg) {
|
|
panic('expected validation to fail')
|
|
}
|
|
}
|
|
|
|
fn test_validate_invalid_priority() {
|
|
cfg := Config{
|
|
server: ServerConfig{
|
|
url: 'https://ntfy.example.com'
|
|
listen: ':9090'
|
|
}
|
|
defaults: DefaultConfig{
|
|
priority: 10
|
|
}
|
|
}
|
|
if _ := validate_config(cfg) {
|
|
panic('expected validation to fail')
|
|
}
|
|
}
|