From 5eb6fd961edb5a217612cdf2a9319405fda1db7d Mon Sep 17 00:00:00 2001 From: 0ceanSlim Date: Wed, 31 Jul 2024 14:12:33 -0400 Subject: [PATCH] rename major package folers web->app, relay->server --- web/http.go => app/app.go | 2 +- {web => app}/favicon.ico | Bin {web => app}/relay_metadata.example.json | 0 {web => app}/relay_metadata.go | 4 ++-- {web => app}/static/custom.min.css | 0 {web => app}/static/img/favicon.ico | Bin {web => app}/style/input.css | 0 {web => app}/style/readme.md | 0 {web => app}/style/tailwind.config.js | 0 {web => app}/views/index.html | 0 {web => app}/views/templates/footer.html | 0 {web => app}/views/templates/header.html | 0 {web => app}/views/templates/layout.html | 0 main.go | 16 ++++++++-------- {relay => server}/db/db.go | 0 {relay => server}/handlers/close.go | 0 {relay => server}/handlers/event.go | 10 +++++----- {relay => server}/handlers/kinds/kind0.go | 4 ++-- {relay => server}/handlers/kinds/kind1.go | 4 ++-- {relay => server}/handlers/kinds/kind2.go | 4 ++-- {relay => server}/handlers/kinds/kind5.go | 4 ++-- {relay => server}/handlers/kinds/regular.go | 4 ++-- {relay => server}/handlers/kinds/replaceable.go | 4 ++-- .../handlers/kinds/replaceableParameters.go | 4 ++-- {relay => server}/handlers/kinds/unknown.go | 4 ++-- {relay => server}/handlers/req.go | 8 ++++---- {relay => server}/handlers/response/closed.go | 0 {relay => server}/handlers/response/notice.go | 0 {relay => server}/handlers/response/ok.go | 0 {relay => server}/relay.go | 2 +- {relay => server}/types/event.go | 0 {relay => server}/types/filter.go | 0 {relay => server}/types/subscription.go | 0 {relay => server}/utils/checkSig.go | 2 +- {relay => server}/utils/convertType.go | 0 {relay => server}/utils/copyFile.go | 0 {relay => server}/utils/ensureFileExists.go | 0 37 files changed, 38 insertions(+), 38 deletions(-) rename web/http.go => app/app.go (99%) rename {web => app}/favicon.ico (100%) rename {web => app}/relay_metadata.example.json (100%) rename {web => app}/relay_metadata.go (94%) rename {web => app}/static/custom.min.css (100%) rename {web => app}/static/img/favicon.ico (100%) rename {web => app}/style/input.css (100%) rename {web => app}/style/readme.md (100%) rename {web => app}/style/tailwind.config.js (100%) rename {web => app}/views/index.html (100%) rename {web => app}/views/templates/footer.html (100%) rename {web => app}/views/templates/header.html (100%) rename {web => app}/views/templates/layout.html (100%) rename {relay => server}/db/db.go (100%) rename {relay => server}/handlers/close.go (100%) rename {relay => server}/handlers/event.go (96%) rename {relay => server}/handlers/kinds/kind0.go (95%) rename {relay => server}/handlers/kinds/kind1.go (90%) rename {relay => server}/handlers/kinds/kind2.go (83%) rename {relay => server}/handlers/kinds/kind5.go (98%) rename {relay => server}/handlers/kinds/regular.go (90%) rename {relay => server}/handlers/kinds/replaceable.go (95%) rename {relay => server}/handlers/kinds/replaceableParameters.go (95%) rename {relay => server}/handlers/kinds/unknown.go (88%) rename {relay => server}/handlers/req.go (97%) rename {relay => server}/handlers/response/closed.go (100%) rename {relay => server}/handlers/response/notice.go (100%) rename {relay => server}/handlers/response/ok.go (100%) rename {relay => server}/relay.go (98%) rename {relay => server}/types/event.go (100%) rename {relay => server}/types/filter.go (100%) rename {relay => server}/types/subscription.go (100%) rename {relay => server}/utils/checkSig.go (98%) rename {relay => server}/utils/convertType.go (100%) rename {relay => server}/utils/copyFile.go (100%) rename {relay => server}/utils/ensureFileExists.go (100%) diff --git a/web/http.go b/app/app.go similarity index 99% rename from web/http.go rename to app/app.go index a2f6c43..228ca41 100644 --- a/web/http.go +++ b/app/app.go @@ -1,4 +1,4 @@ -package web +package app import ( "context" diff --git a/web/favicon.ico b/app/favicon.ico similarity index 100% rename from web/favicon.ico rename to app/favicon.ico diff --git a/web/relay_metadata.example.json b/app/relay_metadata.example.json similarity index 100% rename from web/relay_metadata.example.json rename to app/relay_metadata.example.json diff --git a/web/relay_metadata.go b/app/relay_metadata.go similarity index 94% rename from web/relay_metadata.go rename to app/relay_metadata.go index 1e28ab8..1366dbd 100644 --- a/web/relay_metadata.go +++ b/app/relay_metadata.go @@ -1,4 +1,4 @@ -package web +package app import ( "encoding/json" @@ -19,7 +19,7 @@ type RelayMetadata struct { var relayMetadata RelayMetadata func LoadRelayMetadataJSON() error { - return LoadRelayMetadata("relay_metadata.json") + return LoadRelayMetadata("app/relay_metadata.json") } func LoadRelayMetadata(filename string) error { diff --git a/web/static/custom.min.css b/app/static/custom.min.css similarity index 100% rename from web/static/custom.min.css rename to app/static/custom.min.css diff --git a/web/static/img/favicon.ico b/app/static/img/favicon.ico similarity index 100% rename from web/static/img/favicon.ico rename to app/static/img/favicon.ico diff --git a/web/style/input.css b/app/style/input.css similarity index 100% rename from web/style/input.css rename to app/style/input.css diff --git a/web/style/readme.md b/app/style/readme.md similarity index 100% rename from web/style/readme.md rename to app/style/readme.md diff --git a/web/style/tailwind.config.js b/app/style/tailwind.config.js similarity index 100% rename from web/style/tailwind.config.js rename to app/style/tailwind.config.js diff --git a/web/views/index.html b/app/views/index.html similarity index 100% rename from web/views/index.html rename to app/views/index.html diff --git a/web/views/templates/footer.html b/app/views/templates/footer.html similarity index 100% rename from web/views/templates/footer.html rename to app/views/templates/footer.html diff --git a/web/views/templates/header.html b/app/views/templates/header.html similarity index 100% rename from web/views/templates/header.html rename to app/views/templates/header.html diff --git a/web/views/templates/layout.html b/app/views/templates/layout.html similarity index 100% rename from web/views/templates/layout.html rename to app/views/templates/layout.html diff --git a/main.go b/main.go index 409880c..461012b 100644 --- a/main.go +++ b/main.go @@ -2,12 +2,12 @@ package main import ( "fmt" + "grain/app" "grain/config" configTypes "grain/config/types" - "grain/relay" - "grain/relay/db" - "grain/relay/utils" - "grain/web" + relay "grain/server" + "grain/server/db" + "grain/server/utils" "log" "net/http" @@ -17,7 +17,7 @@ import ( func main() { utils.EnsureFileExists("config.yml", "config/config.example.yml") - utils.EnsureFileExists("relay_metadata.json", "web/relay_metadata.example.json") + utils.EnsureFileExists("app/relay_metadata.json", "app/relay_metadata.example.json") cfg, err := config.LoadConfig("config.yml") if err != nil { @@ -33,7 +33,7 @@ func main() { config.SetupRateLimiter(cfg) config.SetupSizeLimiter(cfg) - err = web.LoadRelayMetadataJSON() + err = app.LoadRelayMetadataJSON() if err != nil { log.Fatal("Failed to load relay metadata: ", err) } @@ -67,8 +67,8 @@ func ListenAndServe(w http.ResponseWriter, r *http.Request) { relay.WebSocketHandler(ws) }).ServeHTTP(w, r) } else if r.Header.Get("Accept") == "application/nostr+json" { - web.RelayInfoHandler(w, r) + app.RelayInfoHandler(w, r) } else { - web.RootHandler(w, r) + app.RootHandler(w, r) } } diff --git a/relay/db/db.go b/server/db/db.go similarity index 100% rename from relay/db/db.go rename to server/db/db.go diff --git a/relay/handlers/close.go b/server/handlers/close.go similarity index 100% rename from relay/handlers/close.go rename to server/handlers/close.go diff --git a/relay/handlers/event.go b/server/handlers/event.go similarity index 96% rename from relay/handlers/event.go rename to server/handlers/event.go index 81fb1dd..cbeabc5 100644 --- a/relay/handlers/event.go +++ b/server/handlers/event.go @@ -5,12 +5,12 @@ import ( "encoding/json" "fmt" "grain/config" - "grain/relay/db" - "grain/relay/handlers/kinds" - "grain/relay/handlers/response" - "grain/relay/utils" + "grain/server/db" + "grain/server/handlers/kinds" + "grain/server/handlers/response" + "grain/server/utils" - relay "grain/relay/types" + relay "grain/server/types" "golang.org/x/net/websocket" ) diff --git a/relay/handlers/kinds/kind0.go b/server/handlers/kinds/kind0.go similarity index 95% rename from relay/handlers/kinds/kind0.go rename to server/handlers/kinds/kind0.go index ad8ffb1..ec1826e 100644 --- a/relay/handlers/kinds/kind0.go +++ b/server/handlers/kinds/kind0.go @@ -3,8 +3,8 @@ package kinds import ( "context" "fmt" - "grain/relay/handlers/response" - relay "grain/relay/types" + "grain/server/handlers/response" + relay "grain/server/types" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" diff --git a/relay/handlers/kinds/kind1.go b/server/handlers/kinds/kind1.go similarity index 90% rename from relay/handlers/kinds/kind1.go rename to server/handlers/kinds/kind1.go index 78c3611..5f2fdcc 100644 --- a/relay/handlers/kinds/kind1.go +++ b/server/handlers/kinds/kind1.go @@ -4,8 +4,8 @@ package kinds import ( "context" "fmt" - "grain/relay/handlers/response" - relay "grain/relay/types" + "grain/server/handlers/response" + relay "grain/server/types" "go.mongodb.org/mongo-driver/mongo" "golang.org/x/net/websocket" diff --git a/relay/handlers/kinds/kind2.go b/server/handlers/kinds/kind2.go similarity index 83% rename from relay/handlers/kinds/kind2.go rename to server/handlers/kinds/kind2.go index c626e97..cdb9ee6 100644 --- a/relay/handlers/kinds/kind2.go +++ b/server/handlers/kinds/kind2.go @@ -2,8 +2,8 @@ package kinds import ( "context" - "grain/relay/handlers/response" - relay "grain/relay/types" + "grain/server/handlers/response" + relay "grain/server/types" "golang.org/x/net/websocket" ) diff --git a/relay/handlers/kinds/kind5.go b/server/handlers/kinds/kind5.go similarity index 98% rename from relay/handlers/kinds/kind5.go rename to server/handlers/kinds/kind5.go index 17dafb1..f314b2d 100644 --- a/relay/handlers/kinds/kind5.go +++ b/server/handlers/kinds/kind5.go @@ -3,8 +3,8 @@ package kinds import ( "context" "fmt" - "grain/relay/handlers/response" - relay "grain/relay/types" + "grain/server/handlers/response" + relay "grain/server/types" "strings" "go.mongodb.org/mongo-driver/bson" diff --git a/relay/handlers/kinds/regular.go b/server/handlers/kinds/regular.go similarity index 90% rename from relay/handlers/kinds/regular.go rename to server/handlers/kinds/regular.go index 86c7d65..f4b57d1 100644 --- a/relay/handlers/kinds/regular.go +++ b/server/handlers/kinds/regular.go @@ -3,8 +3,8 @@ package kinds import ( "context" "fmt" - "grain/relay/handlers/response" - relay "grain/relay/types" + "grain/server/handlers/response" + relay "grain/server/types" "go.mongodb.org/mongo-driver/mongo" "golang.org/x/net/websocket" diff --git a/relay/handlers/kinds/replaceable.go b/server/handlers/kinds/replaceable.go similarity index 95% rename from relay/handlers/kinds/replaceable.go rename to server/handlers/kinds/replaceable.go index 1a6e810..a9f020e 100644 --- a/relay/handlers/kinds/replaceable.go +++ b/server/handlers/kinds/replaceable.go @@ -3,8 +3,8 @@ package kinds import ( "context" "fmt" - "grain/relay/handlers/response" - relay "grain/relay/types" + "grain/server/handlers/response" + relay "grain/server/types" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" diff --git a/relay/handlers/kinds/replaceableParameters.go b/server/handlers/kinds/replaceableParameters.go similarity index 95% rename from relay/handlers/kinds/replaceableParameters.go rename to server/handlers/kinds/replaceableParameters.go index 72ec25c..cdb8f7e 100644 --- a/relay/handlers/kinds/replaceableParameters.go +++ b/server/handlers/kinds/replaceableParameters.go @@ -3,8 +3,8 @@ package kinds import ( "context" "fmt" - "grain/relay/handlers/response" - relay "grain/relay/types" + "grain/server/handlers/response" + relay "grain/server/types" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" diff --git a/relay/handlers/kinds/unknown.go b/server/handlers/kinds/unknown.go similarity index 88% rename from relay/handlers/kinds/unknown.go rename to server/handlers/kinds/unknown.go index acb2e54..3ac357f 100644 --- a/relay/handlers/kinds/unknown.go +++ b/server/handlers/kinds/unknown.go @@ -2,8 +2,8 @@ package kinds import ( "context" - "grain/relay/handlers/response" - relay "grain/relay/types" + "grain/server/handlers/response" + relay "grain/server/types" "go.mongodb.org/mongo-driver/mongo" "golang.org/x/net/websocket" diff --git a/relay/handlers/req.go b/server/handlers/req.go similarity index 97% rename from relay/handlers/req.go rename to server/handlers/req.go index 23f3546..71a9496 100644 --- a/relay/handlers/req.go +++ b/server/handlers/req.go @@ -4,10 +4,10 @@ import ( "context" "encoding/json" "fmt" - "grain/relay/db" - "grain/relay/handlers/response" - relay "grain/relay/types" - "grain/relay/utils" + "grain/server/db" + "grain/server/handlers/response" + relay "grain/server/types" + "grain/server/utils" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" diff --git a/relay/handlers/response/closed.go b/server/handlers/response/closed.go similarity index 100% rename from relay/handlers/response/closed.go rename to server/handlers/response/closed.go diff --git a/relay/handlers/response/notice.go b/server/handlers/response/notice.go similarity index 100% rename from relay/handlers/response/notice.go rename to server/handlers/response/notice.go diff --git a/relay/handlers/response/ok.go b/server/handlers/response/ok.go similarity index 100% rename from relay/handlers/response/ok.go rename to server/handlers/response/ok.go diff --git a/relay/relay.go b/server/relay.go similarity index 98% rename from relay/relay.go rename to server/relay.go index b55d7f8..e72e3d8 100644 --- a/relay/relay.go +++ b/server/relay.go @@ -3,7 +3,7 @@ package relay import ( "encoding/json" "fmt" - "grain/relay/handlers" + "grain/server/handlers" "grain/config" diff --git a/relay/types/event.go b/server/types/event.go similarity index 100% rename from relay/types/event.go rename to server/types/event.go diff --git a/relay/types/filter.go b/server/types/filter.go similarity index 100% rename from relay/types/filter.go rename to server/types/filter.go diff --git a/relay/types/subscription.go b/server/types/subscription.go similarity index 100% rename from relay/types/subscription.go rename to server/types/subscription.go diff --git a/relay/utils/checkSig.go b/server/utils/checkSig.go similarity index 98% rename from relay/utils/checkSig.go rename to server/utils/checkSig.go index f77b495..d505b7d 100644 --- a/relay/utils/checkSig.go +++ b/server/utils/checkSig.go @@ -6,7 +6,7 @@ import ( "encoding/json" "log" - relay "grain/relay/types" + relay "grain/server/types" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/schnorr" diff --git a/relay/utils/convertType.go b/server/utils/convertType.go similarity index 100% rename from relay/utils/convertType.go rename to server/utils/convertType.go diff --git a/relay/utils/copyFile.go b/server/utils/copyFile.go similarity index 100% rename from relay/utils/copyFile.go rename to server/utils/copyFile.go diff --git a/relay/utils/ensureFileExists.go b/server/utils/ensureFileExists.go similarity index 100% rename from relay/utils/ensureFileExists.go rename to server/utils/ensureFileExists.go