mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 01:41:44 +00:00
* feat(database): create schema for hway and motr * fix(gateway): correct naming inconsistencies in handlers * build: update schema file to be compatible with postgresql syntax * fix: update schema to be compatible with PostgreSQL syntax * chore: update query_hway.sql to follow sqlc syntax * ```text refactor: update query_hway.sql for PostgreSQL and sqlc ``` * feat: add vaults table to store encrypted data * refactor: Update vaults table schema for sqlc compatibility * chore(deps): Upgrade dependencies and add pgx/v5 * refactor(Makefile): move sqlc generate to internal/models * docs(foundations): remove outdated pages * chore(build): add Taskfile for build tasks * refactor(embed): move embed files to internal package * docs: add documentation for Cosmos SDK ORM
39 lines
1012 B
Go
39 lines
1012 B
Go
package middleware
|
|
|
|
import (
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/medama-io/go-useragent"
|
|
"github.com/onsonr/sonr/crypto/mpc"
|
|
"github.com/onsonr/sonr/internal/config/hway"
|
|
"github.com/onsonr/sonr/internal/models/drivers/hwayorm"
|
|
"github.com/onsonr/sonr/pkg/common"
|
|
)
|
|
|
|
type GatewayContext struct {
|
|
echo.Context
|
|
agent useragent.UserAgent
|
|
id string
|
|
dbq *hwayorm.Queries
|
|
ipfsClient common.IPFS
|
|
tokenStore common.IPFSTokenStore
|
|
stagedEnclaves map[string]mpc.Enclave
|
|
grpcAddr string
|
|
}
|
|
|
|
func UseGateway(env hway.Hway, ipc common.IPFS, db *hwayorm.Queries) echo.MiddlewareFunc {
|
|
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
|
return func(c echo.Context) error {
|
|
ua := useragent.NewParser()
|
|
ctx := &GatewayContext{
|
|
agent: ua.Parse(c.Request().UserAgent()),
|
|
Context: c,
|
|
dbq: db,
|
|
ipfsClient: ipc,
|
|
grpcAddr: env.GetSonrGrpcUrl(),
|
|
tokenStore: common.NewUCANStore(ipc),
|
|
}
|
|
return next(ctx)
|
|
}
|
|
}
|
|
}
|