Add extensions/v1 API service backed by Cloudflare D1#132
Conversation
Migrates the 4 extension registry endpoints from fossbilling/extension-directory into this Hono Worker, making api.fossbilling.net the canonical host for all FOSSBilling APIs. New endpoints: GET /extensions/v1/list[?type=...] → Extension[] GET /extensions/v1/:id → Extension GET /extensions/v1/:id/version → plain-text semver tag GET /extensions/v1/:id/badges/:type → image/svg+xml badge Data is stored in a new D1 database (DB_EXTENSIONS). Nested fields (author, releases, license, source) are serialised as JSON TEXT. A one-shot seed script at src/services/extensions/v1/scripts/seed-db.ts populates the database from the existing TypeScript data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AHT7incwQNb5yWbCNwi2a2
Replaces the placeholder UUID for DB_EXTENSIONS with the real Cloudflare D1 database ID (c81c21db-2b8b-40da-9ad5-9eda5ec24015, database: extensions_data). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AHT7incwQNb5yWbCNwi2a2
Auto-generated by seed-db.ts from extensions-data.ts. Contains INSERT OR REPLACE statements for all 15 extensions in the registry. Used as the reference seed file; remote execution was performed directly via the Cloudflare D1 MCP connector. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AHT7incwQNb5yWbCNwi2a2
- Add `authors` table to schema with id, type, name, url columns - Change `extensions.author` JSON column to `author_id` FK referencing authors(id) - Add idx_extensions_author index - Update database.ts to JOIN authors on SELECT queries and build Author object from joined columns instead of parsing embedded JSON - Update seed-db.ts to insert authors first then use author_id in extensions - Regenerate seed.sql with new schema (12 authors + 15 extensions) - Re-seed D1 remote database with normalized data Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AHT7incwQNb5yWbCNwi2a2
authors-data.ts, extensions-data.ts, seed-db.ts, and seed.sql were one-time migration artifacts. D1 is now authoritative; schema.sql remains as the canonical DDL for recreating the database structure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AHT7incwQNb5yWbCNwi2a2
Add argsIgnorePattern/varsIgnorePattern to globally ignore _-prefixed identifiers, which is the conventional TypeScript pattern for intentionally unused parameters. Remove now-redundant eslint-disable-next-line comments from d1-mock.ts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AHT7incwQNb5yWbCNwi2a2
Update testExtensions rows to use the new JOIN-based column layout (author_id, author_type, author_name, author_url instead of the old author JSON blob), and update query string matching to use the aliased column references (e.type, LOWER(e.id)) that the new SELECT uses. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AHT7incwQNb5yWbCNwi2a2
…de adapter NOT_FOUND errors from getExtensionById now produce HTTP 404 instead of 500 across all three /:id route handlers. The node platform adapter also lacked DB_EXTENSIONS in its databases map, causing an immediate throw on any extensions route in non-Cloudflare environments; wired in createDefaultAdapter() to match the existing pattern used by other services. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AHT7incwQNb5yWbCNwi2a2
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
api | a7af245 | Commit Preview URL Branch Preview URL |
Jun 25 2026, 04:47 PM |
The createNodeBindings test was asserting databases equals {} but the
adapter now includes DB_EXTENSIONS. Updated assertion to verify the key
exists and holds a SQLiteAdapter instance.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AHT7incwQNb5yWbCNwi2a2
There was a problem hiding this comment.
Pull request overview
Adds a new extensions/v1 service to the Hono worker, intended to make api.fossbilling.net the canonical host for the extension registry API, backed by a new Cloudflare D1 binding.
Changes:
- Introduces
src/services/extensions/v1with list/detail/version/badge endpoints and a small DB access layer + schema. - Wires the new service into the worker router and Cloudflare/Node platform bindings (
DB_EXTENSIONS), and addsbadge-makerdependency. - Adds a dedicated Vitest suite for the new endpoints and updates ESLint unused-vars handling (underscore-prefixed args/vars).
Reviewed changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| wrangler.jsonc | Adds the DB_EXTENSIONS D1 binding configuration. |
| worker-configuration.d.ts | Regenerates Wrangler/workerd types to include DB_EXTENSIONS in bindings. |
| eslint.config.ts | Configures @typescript-eslint/no-unused-vars to ignore underscore-prefixed args/vars. |
| src/app/index.ts | Routes /extensions/v1 to the new extensions service. |
| src/lib/adapters/cloudflare/index.ts | Exposes DB_EXTENSIONS via the Cloudflare D1 adapter. |
| src/lib/adapters/node/index.ts | Adds a default Node DB_EXTENSIONS database binding (in-memory SQLite adapter). |
| src/services/extensions/v1/index.ts | Implements the new extensions API endpoints, including badge rendering. |
| src/services/extensions/v1/interfaces.ts | Defines extension/release domain types and semver-based helpers. |
| src/services/extensions/v1/database.ts | Implements SQL access + row parsing for extensions. |
| src/services/extensions/v1/db/schema.sql | Defines the D1 schema for authors/extensions tables and indexes. |
| test/services/extensions/v1/index.test.ts | Adds endpoint-level tests for list/detail/version/badges behavior. |
| test/utils/d1-mock.ts | Removes now-unneeded eslint disable comments (underscore args). |
| package.json | Adds badge-maker dependency. |
| package-lock.json | Locks badge-maker and its transitive dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@codex review |
extensions/v1 API service backed by Cloudflare D1
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Migrates the 4 extension registry endpoints from
fossbilling/extension-directoryinto this Hono Worker, making api.fossbilling.net the canonical host for all FOSSBilling APIs.New endpoints:
GET /extensions/v1/list[?type=...] → Extension[]
GET /extensions/v1/:id → Extension
GET /extensions/v1/:id/version → plain-text semver tag
GET /extensions/v1/:id/badges/:type → image/svg+xml badge
Data is stored in a new D1 database (
DB_EXTENSIONS). Nested fields (releases, license, source) are serialised as JSON TEXT.