<p align="center">
<svg width="680" height="120" viewBox="0 0 680 120" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="@xemahq/service-registry-nest">
  <rect width="680" height="120" rx="14" fill="#0B1020"/>
  <g transform="translate(28,34)">
    <path d="M26 0 L52 15 L52 45 L26 60 L0 45 L0 15 Z" fill="#8B5CF6" opacity="0.18"/>
    <path d="M26 12 L41 21 L41 39 L26 48 L11 39 L11 21 Z" fill="#8B5CF6"/>
  </g>
  <text x="92" y="52" font-family="ui-monospace,SFMono-Regular,Menlo,monospace" font-size="22" fill="#F8FAFC" font-weight="700">@xemahq/service-registry-nest</text>
  <text x="92" y="80" font-family="ui-sans-serif,system-ui,sans-serif" font-size="15" fill="#94A3B8">NestJS SDK for service registration and typed discovery.</text>
  <text x="652" y="105" text-anchor="end" font-family="ui-sans-serif,system-ui,sans-serif" font-size="12" fill="#475569">xema.dev</text>
</svg>
</p>

<p align="center">
  <a href="https://xema.dev">Website</a> &middot;
  <a href="https://www.npmjs.com/package/@xemahq/service-registry-nest">npm</a>
</p>

<p align="center">
  <img alt="npm" src="https://img.shields.io/npm/v/%40xemahq%2Fservice-registry-nest?color=2563eb&label=npm">
  <img alt="license" src="https://img.shields.io/npm/l/%40xemahq%2Fservice-registry-nest?color=10b981">
  <img alt="types" src="https://img.shields.io/npm/types/%40xemahq%2Fservice-registry-nest?color=3178c6">
</p>

# @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 `@InjectService` when a service needs a typed client to call
  another service over HTTP.

## Installation

```bash
pnpm add @xemahq/service-registry-nest
```

## Usage

```ts
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 &copy; Xema — [xema.dev](https://xema.dev)
