feature/implement vault allocation (#11)

* feat: add authentication middleware

* feat: add REST API endpoints for database interactions

* refactor: move DiscoveryDocument Pkl schema to oidc module

* fix: replace sonrd with test_node.sh

* feat: use NFT keeper to mint DID namespace NFT

* refactor: move NFT class configuration to types

* feat: add GlobalIntegrity genesis state

* fix: ensure GlobalIntegrity is initialized in genesis

* refactor: update all references to transactions module

* refactor: improve genesis state struct

* chore(did): update discovery endpoint to reflect base url

* feat: remove unused context cache and client code

* refactor: remove middleware dependency from keeper

* feat: Add new query handlers for DID module

* feat: Implement unimplemented params queries

* feat: add support for first-party caveats

* refactor: move motr command to cmd directory

* feat: add support for GitHub releases

* fix(motr): build app.wasm for motr package

* feat: add card component

* feat: add IndexedDB support for persistent storage

* feat: Add Row and Column components

* feat: add  and  components

* refactor: improve button component

* refactor: remove unnecessary button parameter in renderButton

* feat: add vault service endpoint

* feat: add input component
This commit is contained in:
Prad Nukala
2024-09-14 12:47:25 -04:00
committed by GitHub
parent bbfe2a2329
commit b593245fe6
133 changed files with 13352 additions and 4247 deletions
+5 -83
View File
@@ -4,12 +4,9 @@
package main
import (
"errors"
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/internal/vfs/wasm"
"github.com/donseba/go-htmx"
"github.com/onsonr/sonr/internal/db"
)
@@ -17,102 +14,27 @@ var dwn *DWN
type DWN struct {
*echo.Echo
DB *db.DB
Htmx *htmx.HTMX
DB *db.DB
}
func main() {
dwn = initRails()
dwn.GET("/", htmxHandler)
dwn.POST("/accounts", accountsHandler)
wasm.Serve(dwn.Echo)
}
// initRails initializes the Rails application
func initRails() *DWN {
// Open the database
cnfg := db.New()
db, err := cnfg.Open()
e := echo.New()
db, err := db.New()
if err != nil {
panic(err.Error())
}
db.ServeEcho(e.Group("/dwn"))
// Initialize the htmx handler
return &DWN{
Echo: echo.New(),
Echo: e,
DB: db,
Htmx: htmx.New(),
}
}
func accountsHandler(e echo.Context) error {
switch e.Request().Method {
case "GET":
case "PUT":
// dwn.DB.AddAccount(e.Param("account"), e.Param("address"))
default:
e.Error(errors.New("Method not allowed"))
}
return e.JSON(200, "OK")
}
func htmxHandler(e echo.Context) error {
// initiate a new htmx handler
h := dwn.Htmx.NewHandler(e.Response(), e.Request())
// check if the request is a htmx request
if h.IsHxRequest() {
// do something
}
// check if the request is boosted
if h.IsHxBoosted() {
// do something
}
// check if the request is a history restore request
if h.IsHxHistoryRestoreRequest() {
// do something
}
// check if the request is a prompt request
if h.RenderPartial() {
// do something
}
// set the headers for the response, see docs for more options
h.PushURL("http://push.url")
h.ReTarget("#ReTarged")
// write the output like you normally do.
// check the inspector tool in the browser to see that the headers are set.
_, err := h.Write([]byte("OK"))
return err
}
//
// func credentialsHandler(e echo.Context) error {
// switch e.Request().Method {
// case "GET":
// dwn.DB.GetCredentials(e.Param("account"))
// case "PUT":
// dwn.DB.AddCredentials(e.Param("account"), e.Param("address"))
// default:
// e.Error(errors.New("Method not allowed"))
// }
// return e.JSON(200, "OK")
// }
//
// func keysharesHandler(e echo.Context) error {
// switch e.Request().Method {
// case "GET":
// dwn.DB.GetKeyshares(e.Param("account"))
// case "PUT":
// dwn.DB.AddKeyshares(e.Param("account"), e.Param("address"))
// default:
// e.Error(errors.New("Method not allowed"))
// }
// return e.JSON(200, "OK")
// }