sonr/cmd/hway/main.go
Prad Nukala 6072f6ecfa
feature/implement wss routes (#1196)
* 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
2024-12-18 20:53:45 +00:00

50 lines
1.1 KiB
Go

package main
import (
"context"
_ "embed"
"fmt"
"os"
"github.com/jackc/pgx/v5"
config "github.com/onsonr/sonr/internal/config/hway"
"github.com/onsonr/sonr/internal/models/drivers/hwayorm"
)
// main is the entry point for the application
func main() {
cmd := rootCmd()
if err := cmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
os.Exit(0)
}
func loadEnvImplFromArgs(args []string) (config.Hway, error) {
cmd := rootCmd()
if err := cmd.ParseFlags(args); err != nil {
return nil, err
}
env := &config.HwayImpl{
ServePort: servePort,
ChainId: chainID,
IpfsGatewayUrl: ipfsGatewayURL,
SonrApiUrl: sonrAPIURL,
SonrGrpcUrl: sonrGrpcURL,
SonrRpcUrl: sonrRPCURL,
PsqlDSN: formatPsqlDSN(),
}
return env, nil
}
func setupPostgresDB() (*hwayorm.Queries, error) {
pgdsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable", psqlHost, psqlUser, psqlPass, psqlDB)
conn, err := pgx.Connect(context.Background(), pgdsn)
if err != nil {
return nil, err
}
return hwayorm.New(conn), nil
}