Skip to main content

getClientToken()

@horizon-republic/nestjs-jetstream


@horizon-republic/nestjs-jetstream / getClientToken

getClientToken()

getClientToken(name, connection?): string

Defined in: src/jetstream.constants.ts:65

Generate the injection token for a forFeature() client.

Use with @Inject() to inject the client created by JetstreamModule.forFeature(). Omitting connection yields the bare service name, the token shape used before named connections existed.

Parameters​

name​

string

The service name passed to forFeature({ name }).

connection?​

string

The connection passed to forFeature({ connection }); omit for the default.

Returns​

string

The DI token string.

Example​

@Inject(getClientToken('orders'))
private readonly ordersClient: JetstreamClient;

@Inject(getClientToken('orders', 'analytics'))
private readonly analyticsOrdersClient: JetstreamClient;