Skip to content

Commit

Permalink
デプロイ時にアクセス可能なURLの例を出力するようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
studiokaiji committed Oct 26, 2023
1 parent c4ffab6 commit 9eed97f
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions hostr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"

"github.com/nbd-wtf/go-nostr"
"github.com/nbd-wtf/go-nostr/nip19"
"github.com/studiokaiji/nostr-webhost/hostr/cmd/deploy"
"github.com/studiokaiji/nostr-webhost/hostr/cmd/keystore"
"github.com/studiokaiji/nostr-webhost/hostr/cmd/relays"
Expand Down Expand Up @@ -48,16 +49,38 @@ func main() {
replaceable := ctx.Bool("replaceable")
dTag := ctx.String("identifier")

id, encoded, err := deploy.Deploy(path, replaceable, dTag)
_, encoded, err := deploy.Deploy(path, replaceable, dTag)
if err == nil {
fmt.Println("🌐 Deploy Complete!")
fmt.Println("index.html:")
fmt.Println(" - event.id:", id)

if !replaceable {
label := " - nevent"
fmt.Printf("%s: %s\n", label, encoded)
pubkey, err := keystore.GetPublic()
if err != nil {
os.Exit(1)
}
npub, err := nip19.EncodePublicKey(pubkey)
if err != nil {
os.Exit(1)
}

defaultModeUrl := "https://h.hostr.cc"
secureModeUrl := fmt.Sprintf("https://%s.h.hostr.cc", npub)

if replaceable {
defaultModeUrl = fmt.Sprintf("%s/p/%s/d/%s", defaultModeUrl, npub, dTag)
secureModeUrl = fmt.Sprintf("%s/d/%s", secureModeUrl, dTag)
} else {
defaultModeUrl = fmt.Sprintf("%s/e/%s", defaultModeUrl, encoded)
secureModeUrl = fmt.Sprintf("%s/e/%s", secureModeUrl, encoded)
}

fmt.Println("\n\033[1m========= 🚵 Access To =========\033")

fmt.Printf("\n\033[1m🗃️ Default Mode:\033[0m\n\x1b[36m%s\x1b[0m\n", defaultModeUrl)
fmt.Printf("\033[1m\n🔑 Secure Mode:\033[0m\n\x1b[36m%s\x1b[0m\n", secureModeUrl)

fmt.Printf("\n\x1b[90mh.hostr.cc is just one endpoint, so depending on the relay configuration, it may not be accessible.\x1b[0m\n")

fmt.Printf("\n\033[1m=================================\033\n")
}
return err
},
Expand Down

0 comments on commit 9eed97f

Please sign in to comment.