Skip to content

unbindapp/unbind-api

Repository files navigation

unbindapp/unbind-api

GitHub License GitHub go.mod Go version

The APIs for the Unbind platform.

Prerequisites (to run locally)

  • Go 1.24 or higher
  • Docker Compose
  • Dex IDP binary installed in $PATH
  1. Clone the repository
  2. Run docker-compose up -d to start dependencies (postgres, redis, etc.)
  3. Run ./startdex.sh to start dex IDP
  4. Reference config/config.go for environment variables, place them in a .env file

Running services

  • go run cmd/api to start the API
    • Visit http://localhost:8089/docs for API documentation
  • go run cmd/oauth2server to start the OAuth2 server
  • go run cmd/cli to execute CLI commands

Generated code

Unbind relies on code generation for some components:

  • ./ent - Generated by ent framework
  • Various interfaces, generated with ifacemaker
  • ./mocks - Generated with mockery

Run go generate ./... to re-generate ent code and interfaces.

Install mockery and run mockery to re-generate mocks.

Core GO Dependencies

  • Huma - REST API Framework
  • ent - Entity framework for GO
  • go-redis - Redis client
  • ifacemaker - Automatically generates interfaces from structs
  • mockery - Automatically creates mocks based on .mockery.yaml

Bootstrapping

Bootsrap superuser:

/app/cli user:create --email=EMAIL --password=PASSWORD
/app/cli group:create --name=superuser --description="Superuser Group"
/app/cli group:add-user --email=EMAIL --group-name=superuser
/app/cli group:grant-permission --group-name=superuser --resource-type=system --resource-id="*" --action=admin
/app/cli group:grant-permission --group-name=superuser --resource-type=team --resource-id="*" --action=admin
/app/cli sync:group-to-k8s

Migrations

  1. Make schema change in ./ent/schema
  2. Re-generate go generate ./ent/...
  3. Make a versioned migration make migrate NAME=your_migration_name

If you edit a migration sql file manually, be sure to re-generate the checksum make migrate-checksum

Releases

No releases published

Packages

 
 
 

Languages