Files
zeekay a9497e711c api-go: Go port scaffold (foundation + auth + chains + projects + wallets)
Lays down the Go skeleton parallel to api/ (FastAPI). Foundation:
  - config: env-driven Settings
  - db: pgx pool + idempotent schema migrations + typed row structs
  - iam: HS256 JWT Verifier + bearer-auth middleware
  - api: chi router with /healthz + /readyz + versioned /v1 mount

Routes ported:
  - /auth: login + signup + refresh (bcrypt + JWT)
  - /chains: registry + status
  - /projects: full CRUD scoped by org
  - /wallets: list + create scoped by project+org

Stubs (route wired, handler returns 501):
  - /api-keys, /webhooks, /rpc, /tokens, /nfts

cmd/bootnode/main.go is the production entrypoint with graceful
shutdown (SIGINT/SIGTERM) and slog JSON logging. Dockerfile builds a
distroless image with CGO disabled.

Remaining surface to port (in order of priority): rpc upstream
dispatcher, api-keys CRUD + auth, tokens + nfts read-only, webhooks
delivery worker, fleet + node + cluster routes, bundler + gas, billing.
The Python service in api/ keeps running until parity ships.
2026-05-13 02:00:07 -07:00

79 lines
1.6 KiB
Go

// Package db — typed row structs corresponding to schema.go tables.
package db
import (
"time"
"github.com/google/uuid"
)
// User mirrors the users table.
type User struct {
ID uuid.UUID
Email string
Name string
PasswordHash *string
Avatar *string
Roles []string
Permissions []string
IsActive bool
LastLoginAt *time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
// Project mirrors the projects table.
type Project struct {
ID uuid.UUID
Name string
OwnerID uuid.UUID
OrgID string
Description *string
Settings map[string]any
AllowedChains []string
CreatedAt time.Time
UpdatedAt time.Time
}
// APIKey mirrors the api_keys table. KeyHash is opaque to the caller;
// the plaintext is shown once at creation and never re-emitted.
type APIKey struct {
ID uuid.UUID
ProjectID uuid.UUID
Name string
KeyHash string
KeyPrefix string
RateLimit int
ComputeUnitsLimit int
AllowedOrigins []string
AllowedChains []string
IsActive bool
LastUsedAt *time.Time
CreatedAt time.Time
}
// Webhook mirrors the webhooks table.
type Webhook struct {
ID uuid.UUID
ProjectID uuid.UUID
Name string
URL string
Secret string
Events []string
IsActive bool
CreatedAt time.Time
UpdatedAt time.Time
}
// Wallet mirrors the wallets table.
type Wallet struct {
ID uuid.UUID
ProjectID uuid.UUID
Chain string
Address string
Label *string
SmartWallet bool
CreatedAt time.Time
UpdatedAt time.Time
}