rename major package folers web->app, relay->server

This commit is contained in:
0ceanSlim 2024-07-31 14:12:33 -04:00
parent f291c07bfa
commit 5eb6fd961e
37 changed files with 38 additions and 38 deletions

View File

@ -1,4 +1,4 @@
package web package app
import ( import (
"context" "context"

View File

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

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

View File

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

16
main.go
View File

@ -2,12 +2,12 @@ package main
import ( import (
"fmt" "fmt"
"grain/app"
"grain/config" "grain/config"
configTypes "grain/config/types" configTypes "grain/config/types"
"grain/relay" relay "grain/server"
"grain/relay/db" "grain/server/db"
"grain/relay/utils" "grain/server/utils"
"grain/web"
"log" "log"
"net/http" "net/http"
@ -17,7 +17,7 @@ import (
func main() { func main() {
utils.EnsureFileExists("config.yml", "config/config.example.yml") 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") cfg, err := config.LoadConfig("config.yml")
if err != nil { if err != nil {
@ -33,7 +33,7 @@ func main() {
config.SetupRateLimiter(cfg) config.SetupRateLimiter(cfg)
config.SetupSizeLimiter(cfg) config.SetupSizeLimiter(cfg)
err = web.LoadRelayMetadataJSON() err = app.LoadRelayMetadataJSON()
if err != nil { if err != nil {
log.Fatal("Failed to load relay metadata: ", err) log.Fatal("Failed to load relay metadata: ", err)
} }
@ -67,8 +67,8 @@ func ListenAndServe(w http.ResponseWriter, r *http.Request) {
relay.WebSocketHandler(ws) relay.WebSocketHandler(ws)
}).ServeHTTP(w, r) }).ServeHTTP(w, r)
} else if r.Header.Get("Accept") == "application/nostr+json" { } else if r.Header.Get("Accept") == "application/nostr+json" {
web.RelayInfoHandler(w, r) app.RelayInfoHandler(w, r)
} else { } else {
web.RootHandler(w, r) app.RootHandler(w, r)
} }
} }

View File

@ -5,12 +5,12 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"grain/config" "grain/config"
"grain/relay/db" "grain/server/db"
"grain/relay/handlers/kinds" "grain/server/handlers/kinds"
"grain/relay/handlers/response" "grain/server/handlers/response"
"grain/relay/utils" "grain/server/utils"
relay "grain/relay/types" relay "grain/server/types"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"
) )

View File

@ -3,8 +3,8 @@ package kinds
import ( import (
"context" "context"
"fmt" "fmt"
"grain/relay/handlers/response" "grain/server/handlers/response"
relay "grain/relay/types" relay "grain/server/types"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"

View File

@ -4,8 +4,8 @@ package kinds
import ( import (
"context" "context"
"fmt" "fmt"
"grain/relay/handlers/response" "grain/server/handlers/response"
relay "grain/relay/types" relay "grain/server/types"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"

View File

@ -2,8 +2,8 @@ package kinds
import ( import (
"context" "context"
"grain/relay/handlers/response" "grain/server/handlers/response"
relay "grain/relay/types" relay "grain/server/types"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"
) )

View File

@ -3,8 +3,8 @@ package kinds
import ( import (
"context" "context"
"fmt" "fmt"
"grain/relay/handlers/response" "grain/server/handlers/response"
relay "grain/relay/types" relay "grain/server/types"
"strings" "strings"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"

View File

@ -3,8 +3,8 @@ package kinds
import ( import (
"context" "context"
"fmt" "fmt"
"grain/relay/handlers/response" "grain/server/handlers/response"
relay "grain/relay/types" relay "grain/server/types"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"

View File

@ -3,8 +3,8 @@ package kinds
import ( import (
"context" "context"
"fmt" "fmt"
"grain/relay/handlers/response" "grain/server/handlers/response"
relay "grain/relay/types" relay "grain/server/types"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"

View File

@ -3,8 +3,8 @@ package kinds
import ( import (
"context" "context"
"fmt" "fmt"
"grain/relay/handlers/response" "grain/server/handlers/response"
relay "grain/relay/types" relay "grain/server/types"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"

View File

@ -2,8 +2,8 @@ package kinds
import ( import (
"context" "context"
"grain/relay/handlers/response" "grain/server/handlers/response"
relay "grain/relay/types" relay "grain/server/types"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"

View File

@ -4,10 +4,10 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"grain/relay/db" "grain/server/db"
"grain/relay/handlers/response" "grain/server/handlers/response"
relay "grain/relay/types" relay "grain/server/types"
"grain/relay/utils" "grain/server/utils"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"

View File

@ -3,7 +3,7 @@ package relay
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"grain/relay/handlers" "grain/server/handlers"
"grain/config" "grain/config"

View File

@ -6,7 +6,7 @@ import (
"encoding/json" "encoding/json"
"log" "log"
relay "grain/relay/types" relay "grain/server/types"
"github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/btcsuite/btcd/btcec/v2/schnorr"