Skip to main content

API Client Registry (Provider-only)

Overview

The api_client table records which external systems connect into the platform. It works alongside API Keys, which is the part that actually has a management UI.

On the cms-api side this module exposes no HTTP routes at all — the original NestJS module declared controllers: []. What it does provide is an exported ApiClientRepository for other modules to use.

Its real consumer is Audience Management, which needs to resolve which client owns a given data source when building an audience from external data.

This page exists as its own feature entry so readers who spot the module name in cmd/api/modules.go and then fail to find any routes are not left guessing.

Business Flow

  1. apiclient.RegisterRoutes is called from cmd/api/modules.go under the same contract as every other module, but its body is intentionally empty, marked with the comment Intentionally empty — ApiClientModule has controllers: [].
  2. Modules that need it construct the service themselves via apiclient.NewService(deps).
  3. The service offers a flexible query interface: the caller passes in a GORM query-scope callback, standing in for TypeORM's FindManyOptions and FindOneOptions, so where clauses and relations can still be expressed the same way.
  4. Soft deletes are handled automatically. The entity declares gorm.DeletedAt, so GORM appends deleted_date IS NULL on its own — matching the TypeORM @DeleteDateColumn that was not configured with select:false.
  5. The audience service uses the result when resolving that audience's data source and permissions.

Key Files & Functions

The code lives in internal/modules/apiclient/.

FileRole
controller.goRegisterRoutes(_, _, _) — intentionally a no-op (0 routes)
service.goService, a port of ApiClientRepository, with a stateless NewService(d)

Endpoints: none

Connections to Other Services

  • Permission — no routes, therefore no guards.
  • Tablesapi_client.
  • Consumers — Audience Management (the TypeScript audience.service injected ApiClientRepository).
  • Related — API Key, the module that carries the actual management UI.