package main import ( "net/http" "git.minhas.io/asara/gologger" "git.minhas.io/asara/well-goknown/config" "git.minhas.io/asara/well-goknown/db" "git.minhas.io/asara/well-goknown/matrix" "git.minhas.io/asara/well-goknown/nostr" "github.com/fiatjaf/eventstore/postgresql" ) func main() { l := gologger.Get(config.GetConfig().LogLevel).With().Str("context", "main").Logger() db, _ := db.NewDB() defer db.Close() nostr.DB = db nostr.RelayDb = postgresql.PostgresBackend{DatabaseURL: config.GetConfig().DbUrl} if err := nostr.RelayDb.Init(); err != nil { l.Panic().Msgf("unable to connect to relay db: %s", err.Error()) } relay := nostr.NewRelay() // matrix endpoints l.Debug().Msg("enabling matrix well-known endpoints") http.HandleFunc("/.well-known/matrix/server", matrix.MatrixServer) http.HandleFunc("/.well-known/matrix/client", matrix.MatrixClient) // nostr endpoints l.Debug().Msg("enabling nostr well-known endpoints") http.HandleFunc("/.well-known/nostr.json", nostr.GetNostrAddr) http.Handle("/relay", relay) // start server port := config.GetConfig().ListenAddr l.Info().Msgf("starting server on %s", port) http.ListenAndServe(port, nil) }