Skip to content

feat: add domain option for custom domain/subdomain routing#10

Open
simulieren wants to merge 1 commit intomainfrom
feat/custom-domain-routing
Open

feat: add domain option for custom domain/subdomain routing#10
simulieren wants to merge 1 commit intomainfrom
feat/custom-domain-routing

Conversation

@simulieren
Copy link
Owner

Summary

  • Adds a domain config option that restricts all server-stats routes to a specific domain or subdomain
  • Uses AdonisJS's native router.group().domain() API
  • Supports both fixed domains (admin.example.com) and dynamic subdomains (:tenant.example.com)

Usage

import { defineConfig } from 'adonisjs-server-stats'

export default defineConfig({
  domain: 'admin.example.com',
  // ... other config
})

Changes

  • ServerStatsConfig and ResolvedServerStatsConfig gain domain?: string
  • AdonisRouter type shim updated with AdonisRouteGroup interface supporting .domain() chaining
  • All route registrars (stats, debug, dashboard) conditionally apply .domain() when configured
  • defineConfig() passes domain through to resolved config
  • 5 new tests covering config resolution and route registration with/without domain

Test plan

  • defineConfig({ domain: 'admin.example.com' }) passes domain to resolved config
  • defineConfig({}) leaves domain undefined (no behavior change)
  • Dynamic subdomain syntax (:tenant.example.com) works
  • All route groups receive .domain() when domain is set
  • No .domain() called when domain is not configured
  • Full build passes
  • TypeScript typecheck passes

Closes #9

🤖 Generated with Claude Code

Add a `domain` config option that restricts all server-stats routes
(stats endpoint, debug panel, dashboard) to a specific domain or
subdomain. Uses AdonisJS's native `router.group().domain()` API.

Usage:
  defineConfig({ domain: 'admin.example.com' })
  defineConfig({ domain: ':tenant.example.com' })  // dynamic

Changes:
- Add `domain?: string` to ServerStatsConfig and ResolvedServerStatsConfig
- Update AdonisRouter type shim with AdonisRouteGroup supporting .domain()
- Pass domain through registerAllRoutes to all sub-registrars
- Stats route wraps in a group when domain is set
- Debug and dashboard route groups conditionally chain .domain()
- Add tests for config resolution and route registration

Closes #9

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Custom domain for dashboard

1 participant