Skip to content

Latest commit

 

History

History
110 lines (75 loc) · 2.38 KB

README.md

File metadata and controls

110 lines (75 loc) · 2.38 KB

@ubiquity-os-marketplace/command-query-user

This package helps users querying their information, from their wallet address or current XP.

Technical Architecture

Core Components

  • GitHub Bot Integration: Built as a Cloudflare Worker that processes GitHub comment webhooks
  • Supabase Database: Stores user-related data including:
    • Wallet addresses
  • Access Control: Supports both public queries and repository collaborator-only queries
  • Type Safety: Comprehensive TypeScript implementation with runtime type validation using TypeBox

Key Technologies

  • Runtime: Cloudflare Workers (Edge Computing Platform)
  • Database: Supabase (PostgreSQL)
  • Framework: Hono (Lightweight web framework)
  • SDK: @ubiquity-os/plugin-sdk for standardized plugin development
  • Type Validation: @sinclair/typebox for runtime type checking
  • GitHub Integration: @octokit/rest for GitHub API interactions

Command Processing Flow

  1. Webhook receives GitHub comment event
  2. Command parser validates the syntax (/query @user)
  3. Access control check (if enabled)
  4. User data retrieval from Supabase
  5. Response formatting and posting as GitHub comment

Usage

The following commands are allowed:

/query @user

Response Format:

| Property | Value |
| -------- | ----- |
| Wallet   | 0x... |
| Access   | [...] |

Running locally

Supabase types

You can run the type generations against a local database with

bun run supabase:generate:local

Or against an instance by setting the SUPABASE_ACCESS_TOKEN and SUPABASE_PROJECT_ID in your .env file

bun run prebuild

Worker

Start the Worker by running

bun run dev

Make requests

To trigger the worker, POST requests should be made to http://localhost:4000 with a Content-Type: application/json header and a body looking like

{
  "stateId": "",
  "eventName": "",
  "eventPayload": "",
  "settings": "",
  "ref": ""
}

For convenience, you can find an .http file with a valid request here.

Configuration

Configuration Options

  • allowPublicQuery: Enable/disable public user queries
  • logLevel: Set logging verbosity (INFO, ERROR, etc.)

Testing

Jest

To start Jest tests, run

bun run test

Development Requirements

  • Bun runtime
  • Supabase CLI (for local development)