feat: implement account, profile, network, and activity management

This commit is contained in:
2025-06-07 10:40:04 +08:00
commit 2f8cd28ee7
135 changed files with 11665 additions and 0 deletions

69
config/config.go Normal file
View File

@@ -0,0 +1,69 @@
//go:build js && wasm
// +build js,wasm
package config
import (
"time"
"github.com/syumai/workers/cloudflare"
)
type Config struct {
Cache CacheSettings `json:"cache"` // Added Cache configuration
Sonr NetworkParams `json:"network"`
DefaultExpiry time.Duration `json:"expiry"`
}
type NetworkParams struct {
SonrChainID string `json:"sonr_chain_id"`
SonrAPIURL string `json:"sonr_api_url"`
SonrRPCURL string `json:"sonr_rpc_url"`
IPFSGateway string `json:"ipfs_gateway"`
}
// CacheSettings defines the configuration for Cloudflare cache
type CacheSettings struct {
Enabled bool `json:"enabled"`
DefaultMaxAge int `json:"default_max_age"`
BypassHeader string `json:"bypass_header"`
BypassValue string `json:"bypass_value"`
CacheableStatusCodes []int `json:"cacheable_status_codes"`
CacheableContentTypes []string `json:"cacheable_content_types"`
}
func Get() Config {
cache := CacheSettings{
Enabled: true,
DefaultMaxAge: 60, // 1 minute by default
BypassHeader: "X-Cache-Bypass",
BypassValue: "true",
CacheableStatusCodes: []int{
200, 301, 302,
},
CacheableContentTypes: []string{
"text/html",
"text/css",
"text/javascript",
"application/javascript",
"application/json",
"image/jpeg",
"image/png",
"image/gif",
"image/webp",
},
}
sonr := NetworkParams{
SonrChainID: cloudflare.Getenv("SONR_CHAIN_ID"),
SonrAPIURL: cloudflare.Getenv("SONR_API_URL"),
SonrRPCURL: cloudflare.Getenv("SONR_RPC_URL"),
IPFSGateway: cloudflare.Getenv("IPFS_GATEWAY"),
}
c := Config{
Sonr: sonr,
Cache: cache,
DefaultExpiry: time.Hour * 1,
}
return c
}

28
config/routes.go Normal file
View File

@@ -0,0 +1,28 @@
//go:build js && wasm
// +build js,wasm
package config
import (
"github.com/labstack/echo/v4"
"github.com/sonr-io/motr/handlers"
)
// ╭────────────────────────────────────────────────╮
// │ HTTP Routes │
// ╰────────────────────────────────────────────────╯
func RegisterViews(e *echo.Echo) {
e.GET("/", handlers.RenderHomePage)
e.GET("/login", handlers.RenderLoginPage)
e.GET("/register", handlers.RenderRegisterPage)
}
func RegisterPartials(e *echo.Echo) {
e.POST("/login/:handle/check", handlers.HandleLoginCheck)
e.POST("/login/:handle/finish", handlers.HandleLoginFinish)
e.POST("/register/:handle", handlers.HandleRegisterStart)
e.POST("/register/:handle/check", handlers.HandleRegisterCheck)
e.POST("/register/:handle/finish", handlers.HandleRegisterFinish)
e.POST("/status", handlers.HandleStatusCheck)
}