Add YAML config loading with validation, env overrides for secrets, and a web dashboard exposing health, stats, and recent events.
2.5 KiB
2.5 KiB
Contributing to ntfy-bridge
Stack
- Langage : V — compilé, rapide, syntaxe proche de Go
- Dépendances : Zéro dépendance externe (stdlib V uniquement)
- Build :
v .→ binaire natif statique
Setup développement
# Installer V
curl -s https://github.com/vlang/v/releases/latest/download/v_linux.zip -o /tmp/v.zip
unzip /tmp/v.zip -d /tmp && sudo /tmp/v/v symlink
# Cloner
git clone https://git.dracodev.net/bruno/ntfy-bridge.git
cd ntfy-bridge
# Compiler (mode dev avec hot reload)
v watch run .
# Tests
v test .
# Build production
v -prod .
Structure du code
.
├── main.v # Entrypoint, flag parsing, orchestration
├── config.v # Config loading + validation
├── server.v # HTTP server, webhook routing
├── ntfy.v # Ntfy HTTP client
├── dedup.v # Deduplication + rate limiting
├── template.v # Mini template engine
├── log.v # Structured logging
├── docker_watcher.v # Docker socket watcher (Unix)
├── sources/ # Event types + source-specific transformers
│ ├── event.v
│ ├── gitea.v
│ ├── uptime_kuma.v
│ ├── docker.v
│ ├── http_poll.v
│ ├── generic.v
│ └── cron.v
└── *_test.v # Unit tests
Ajouter une nouvelle source
- Créer
sources/ma_source.v - Implémenter la fonction
transform(raw string, source MaSource) ?Event - Déclarer le type source dans
sources/event.v - Référencer le type dans
config.v(SourcesConfig) - Router l'endpoint dans
server.v - Ajouter un test dans
ma_source_test.v
Conventions de code
- Nommage : snake_case pour les fonctions/variables, PascalCase pour les structs
- Gestion d'erreurs : utiliser le type
?(Option/Result) de V - Logging :
log.info(),log.warn(),log.error()avec contexte - Messages de commit : Conventional Commits
feat: add Gitea webhook transformerfix: handle Docker socket disconnectdocs: update ARCHITECTURE.md
Tests
# Tous les tests
v test .
# Test spécifique
v test gitea_test.v
# Avec verbose
v test . -stats
CI/CD
Le repo utilise Gitea Actions. Le workflow dans .gitea/workflows/ci.yml :
- Compile en mode
-prod - Lance
v test . - Vérifie le formatting (
v fmt -verify)
Questions ?
Ouvrir une issue sur https://git.dracodev.net/bruno/ntfy-bridge/issues