config generation refactor cleanup

This commit is contained in:
0ceanSlim 2024-07-31 14:41:48 -04:00
parent 5eb6fd961e
commit ad42f1fc39
5 changed files with 9 additions and 8 deletions

View File

@ -2,8 +2,8 @@ package app
import (
"context"
"grain/relay/db"
relay "grain/relay/types"
"grain/server/db"
relay "grain/server/types"
"html/template"
"net/http"

View File

@ -7,6 +7,7 @@ import (
configTypes "grain/config/types"
relay "grain/server"
"grain/server/db"
"grain/server/nip"
"grain/server/utils"
"log"
@ -16,8 +17,8 @@ import (
)
func main() {
utils.EnsureFileExists("config.yml", "config/config.example.yml")
utils.EnsureFileExists("app/relay_metadata.json", "app/relay_metadata.example.json")
utils.EnsureFileExists("config.yml", "app/static/examples/config.example.yml")
utils.EnsureFileExists("relay_metadata.json", "app/static/examples/relay_metadata.example.json")
cfg, err := config.LoadConfig("config.yml")
if err != nil {
@ -33,7 +34,7 @@ func main() {
config.SetupRateLimiter(cfg)
config.SetupSizeLimiter(cfg)
err = app.LoadRelayMetadataJSON()
err = nip.LoadRelayMetadataJSON()
if err != nil {
log.Fatal("Failed to load relay metadata: ", err)
}
@ -67,7 +68,7 @@ func ListenAndServe(w http.ResponseWriter, r *http.Request) {
relay.WebSocketHandler(ws)
}).ServeHTTP(w, r)
} else if r.Header.Get("Accept") == "application/nostr+json" {
app.RelayInfoHandler(w, r)
nip.RelayInfoHandler(w, r)
} else {
app.RootHandler(w, r)
}

View File

@ -1,4 +1,4 @@
package app
package nip
import (
"encoding/json"
@ -19,7 +19,7 @@ type RelayMetadata struct {
var relayMetadata RelayMetadata
func LoadRelayMetadataJSON() error {
return LoadRelayMetadata("app/relay_metadata.json")
return LoadRelayMetadata("relay_metadata.json")
}
func LoadRelayMetadata(filename string) error {