server

command module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2026 License: MIT Imports: 9 Imported by: 0

README

supatype-server

Unified API gateway for the Supatype platform — local dev, self-host, and production.

Product: github.com/supatype · Docs: supatype.github.io/supatype

Most users run this via the CLI (supatype dev or supatype self-host compose up) — you only need this repo if you are hacking on the server itself.

Repository: github.com/supatype/server

Overview

supatype-server is the unified Supatype runtime process. It includes the Auth API and also serves as the API edge/gateway for other Supatype services.

It can:

  • Run Auth (/auth/v1) with migrations and background workers.
  • Proxy PostgREST (/rest/v1) and GraphQL (/graphql/v1).
  • Serve Storage via built-in local filesystem mode or proxy mode (/storage/v1).
  • Proxy Edge Functions to a functions worker or in-process Deno (/functions/v1).
  • Expose Functions admin endpoints (/functions/v1/admin).
  • Serve Realtime WebSockets when enabled (/realtime/v1).
  • Expose admin and Studio support endpoints (/admin/v1, /studio-config, /sql).
  • Serve application content from / (none/static/proxy modes).

Route Map

  • /auth/v1/* -> Auth API
  • /rest/v1/* -> PostgREST
  • /graphql/v1/* -> GraphQL
  • /storage/v1/* -> local storage handler or storage proxy
  • /functions/v1/admin/* -> functions admin API
  • /functions/v1/* -> Deno functions proxy
  • /realtime/v1/* -> realtime WebSocket handler
  • /admin/v1/* -> admin API
  • /studio-config -> Studio config payload
  • /sql -> SQL runner endpoint
  • /* -> app runtime (none, static, or proxy)

Runtime Modes

Set SUPATYPE_MODE to control gateway behavior:

  • dev (default): permissive CORS and optional dev-proxy behavior.
  • standalone: automatic ACME/TLS support for direct hosting.
  • managed: tenant HMAC verification middleware (hosted multi-tenant gateway).

Quick Start

Using Supatype as a product? Run npx supatype@latest init then supatype dev — see docs. The steps below are for server contributors cloning this repo.

Prerequisites
  • Go 1.25+
  • Docker (for local Postgres with the provided compose file)
1) Configure environment

Create .env from example.env and set required values (especially DB and JWT values).

2) Start local Postgres
docker-compose -f docker-compose-dev.yml up -d postgres
3) Build
make build

Or with plain Go:

go build -o supatype-server .
4) Run
./supatype-server

Health check:

CLI Commands

Default supatype-server behavior runs migrations and then starts serving.

Available commands:

  • supatype-server serve
  • supatype-server migrate
  • supatype-server version
  • supatype-server admin createuser <email> <password> [role]
  • supatype-server admin deleteuser <email-or-uuid>

Configuration

supatype-server reads:

  • Auth/API config from .env and GOTRUE_* environment variables.
  • Server/gateway config from SUPATYPE_* variables.
  • Optional route manifest (default .supatype/manifest.json).

Common SUPATYPE_* variables:

  • SUPATYPE_MODE
  • SUPATYPE_APP_MODE
  • SUPATYPE_APP_STATIC_DIR
  • SUPATYPE_APP_UPSTREAM
  • SUPATYPE_MANIFEST_PATH
  • SUPATYPE_POSTGREST_URL
  • SUPATYPE_GRAPHQL_URL
  • SUPATYPE_STORAGE_URL
  • SUPATYPE_FUNCTIONS_WORKER_URL
  • SUPATYPE_DENO_PATH
  • SUPATYPE_DENO_FUNCTIONS_DIR
  • SUPATYPE_DENO_PORT
  • SUPATYPE_TENANT_HMAC_SECRET
  • SUPATYPE_TLS_DOMAIN

Local storage mode:

  • STORAGE_PROVIDER=local
  • STORAGE_PATH=<directory>

Migrations

Migrations are run automatically when starting supatype-server directly.

Run manually:

./supatype-server migrate

Development

make build
make test
make vet
make static
make format

Dev container helpers:

make dev
make down

License

See LICENSE.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
client
admin
Package admin provides primitives to interact with the openapi HTTP API.
Package admin provides primitives to interact with the openapi HTTP API.
Package classification gotrue
Package classification gotrue
internal
admin
Package admin provides HTTP handlers for the /admin/v1 API.
Package admin provides HTTP handlers for the /admin/v1 API.
api
api/apitask
Package apitask provides a background execution context for background work that limits the execution time to the current request.
Package apitask provides a background execution context for background work that limits the execution time to the current request.
dbpool
Package dbpool provides the process-wide Postgres pool used by server-side features that read the project database directly — the Studio SQL runner and Studio membership lookups.
Package dbpool provides the process-wide Postgres pool used by server-side features that read the project database directly — the Studio SQL runner and Studio membership lookups.
e2e
Package e2e provides a few utilities for use in unit tests.
Package e2e provides a few utilities for use in unit tests.
e2e/e2eapi
Package e2eapi provides utilities for end-to-end testing the api.
Package e2eapi provides utilities for end-to-end testing the api.
e2e/e2ehooks
Package e2ehooks provides utilities for end-to-end testing of hooks.
Package e2ehooks provides utilities for end-to-end testing of hooks.
functions
Package functions provides the studio admin API for edge functions.
Package functions provides the studio admin API for edge functions.
hooks/hookserrors
Package hookserrors holds the Error type and some functions to Check responses for errors.
Package hookserrors holds the Error type and some functions to Check responses for errors.
mailer
Package mailer defines the GoTrue mail abstraction.
Package mailer defines the GoTrue mail abstraction.
mailer/consoleclient
Package consoleclient implements mailer.Client by logging structured email metadata.
Package consoleclient implements mailer.Client by logging structured email metadata.
mailer/mailmeclient
Package mailmeclient provides an implementation of mailer.Client that uses gopkg.in/gomail.v2 to send via SMTP.
Package mailmeclient provides an implementation of mailer.Client that uses gopkg.in/gomail.v2 to send via SMTP.
mailer/noopclient
Package noopclient provides an implementation of mailer.Client that simply does nothing.
Package noopclient provides an implementation of mailer.Client that simply does nothing.
mailer/resendclient
Package resendclient implements mailer.Client using the Resend API.
Package resendclient implements mailer.Client using the Resend API.
mailer/sesclient
Package sesclient implements mailer.Client using AWS SES v2.
Package sesclient implements mailer.Client using AWS SES v2.
mailer/taskclient
Package taskclient provides an implementation of mailer.Client that uses the apitask package to send mail in the background.
Package taskclient provides an implementation of mailer.Client that uses the apitask package to send mail in the background.
maskedfields
Package maskedfields tells a REST caller which columns in a response may have been masked.
Package maskedfields tells a REST caller which columns in a response may have been masked.
modelhooks
Package modelhooks runs a project's schema-declared lifecycle hooks on the REST write path.
Package modelhooks runs a project's schema-declared lifecycle hooks on the REST write path.
objstore
Package objstore implements a Supabase-compatible object storage HTTP handler backed by the local filesystem.
Package objstore implements a Supabase-compatible object storage HTTP handler backed by the local filesystem.
platformproxy
Package platformproxy reverse-proxies /platform/v1 to the self-host control plane sidecar.
Package platformproxy reverse-proxies /platform/v1 to the self-host control plane sidecar.
reloader
Package reloader provides support for live configuration reloading.
Package reloader provides support for live configuration reloading.
sqlrunner
Package sqlrunner provides the studio SQL-runner HTTP handler.
Package sqlrunner provides the studio SQL-runner HTTP handler.
studiobootstrap
Package studiobootstrap answers "what may this caller see and do" from the access rules the schema declared, so Studio does not have to guess.
Package studiobootstrap answers "what may this caller see and do" from the access rules the schema declared, so Studio does not have to guess.
studiomembers
Package studiomembers resolves Studio capability from the project database.
Package studiomembers resolves Studio capability from the project database.
Send-email hook receiver (POST /internal/v0hooks/send-email).
Send-email hook receiver (POST /internal/v0hooks/send-email).

Jump to

Keyboard shortcuts

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