@xemahq/service-registry-nest
v0.1.7
Published
NestJS runtime SDK for the Xema OS Service Registry (Phase B.2). Provides `ServiceRegistryModule.forRootAsync()` — registers the host service's `ServiceDescriptor` against KernelState at boot, renews the lease on a heartbeat, removes the entry on shutdown
Readme
@xemahq/service-registry-nest
NestJS SDK for service registration and typed discovery.
Overview
A NestJS module that registers the host service's descriptor with the service
registry at boot, renews its lease on a heartbeat, and removes the entry on
shutdown. The @InjectService(name) decorator hands consumers a typed HTTP
client whose base URL is resolved from the registry on every call, so callers
never hard-code another service's address. The SDK is adapter-agnostic: the
backing registry is supplied through a factory, so the same code runs against a
local development adapter or a clustered one.
When to use it
- Use it so a service self-registers at boot and discovers its peers by name rather than by configured URL.
- Reach for
@InjectServicewhen a service needs a typed client to call another service over HTTP.
Installation
pnpm add @xemahq/service-registry-nestUsage
import { InjectService, TypedServiceClient } from '@xemahq/service-registry-nest';
@Injectable()
export class UsersGateway {
constructor(
@InjectService('identity-api') private readonly identity: TypedServiceClient,
) {}
getUser(id: string) {
return this.identity.get(`/users/${id}`);
}
}Peer requirements
@nestjs/common,@nestjs/core— host framework.reflect-metadata— decorator metadata runtime.
License
Apache-2.0 © Xema — xema.dev
