server

package
v0.0.0-...-3460070 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() (*http.Server, error)

New builds the HTTP server, wiring middleware, dependencies, and routes.

func ProvisionUser

func ProvisionUser(client *convex.Client) func(ctx context.Context, token string) (string, error)

ProvisionUser exchanges a validated token for the caller's Convex users._id, creating the row on first contact. Idempotent — the web client calls the same mutation at sign-in (PRD §11, §13). Returned as a func, not a method, so the WS handler can hold it as a field the tests can stub without a real Convex deployment.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server holds the Echo instance and shared dependencies. Handlers are methods on Server so they can reach dependencies without package-level globals.

func (*Server) RegisterRoutes

func (s *Server) RegisterRoutes()

RegisterRoutes wires all HTTP routes. Kept separate from server lifecycle so the route table is easy to scan in one place.

type TokenValidator

type TokenValidator struct {
	// contains filtered or unexported fields
}

TokenValidator verifies Clerk-issued JWTs against the instance JWKS (PRD §13). It is the only component that knows what "authenticated" means; everything past the WS upgrade treats identity as message data.

func NewTokenValidator

func NewTokenValidator(ctx context.Context, issuer string) (*TokenValidator, error)

NewTokenValidator fetches the JWKS for issuer and keeps it refreshed in the background (keyfunc handles caching and kid rotation).

func (*TokenValidator) Validate

func (v *TokenValidator) Validate(tokenString string) (string, error)

Validate checks signature, issuer, audience, and expiry, and returns the subject (the Clerk user id, which Convex stores as users.authId).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL