mirror of
https://github.com/cf-sonr/radar.git
synced 2026-01-12 02:59:13 +00:00
feat: implement account, profile, network, and activity management
This commit is contained in:
69
config/config.go
Normal file
69
config/config.go
Normal 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
28
config/routes.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user