ワンクリックで
getting-started
Use when configuring NATS messaging, subscribers, or the simple NatsClient in NestJS applications.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when configuring NATS messaging, subscribers, or the simple NatsClient in NestJS applications.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | getting-started |
| description | Use when configuring NATS messaging, subscribers, or the simple NatsClient in NestJS applications. |
Use NatsModule.forRoot(...) for decorator-driven subscribers, consumers,
services, and streams. Use NatsClientModule.forRootAsync(...) when you only
need the fire-and-forget NatsClient publisher.
import { Module } from '@nestjs/common'
import { NatsModule } from '@wisemen/nestjs-nats'
@Module({
imports: [
NatsModule.forRoot({
modules: [MySubscriberModule, MyConsumerModule],
defaultClient: MyNatsConnection,
streams: [MyStream]
})
]
})
export class NatsAppModule {}
import { ConfigService } from '@nestjs/config'
import { NatsConnection, NatsSubscriber, OnNatsMessage, NatsMessageData, NatsMsgDataJsonPipe } from '@wisemen/nestjs-nats'
@NatsConnection((config: ConfigService) => ({
name: 'default',
servers: config.getOrThrow('NATS_ENDPOINT')
}))
export class MyNatsConnection {}
@NatsSubscriber(() => ({
subject: 'my.subject',
name: 'my-subscriber'
}))
export class MySubscriber {
@OnNatsMessage()
async handle (@NatsMessageData(NatsMsgDataJsonPipe) payload: unknown): Promise<void> {
console.info(payload)
}
}
import { Module } from '@nestjs/common'
import { ConfigService } from '@nestjs/config'
import { credsAuthenticator } from '@nats-io/transport-node'
import { NatsClientModule } from '@wisemen/nestjs-nats'
@Module({
imports: [NatsClientModule.forRootAsync({
inject: [ConfigService],
useFactory: (config: ConfigService) => ({
client: {
servers: config.getOrThrow('NATS_ENDPOINT'),
authenticator: credsAuthenticator(
new TextEncoder().encode(config.getOrThrow('NATS_CREDS'))
)
},
onConnectError: (error) => {
console.error('Initial NATS connection failed', error)
}
})
})],
exports: [NatsClientModule]
})
export class OutboundNatsModule {}
client is passed directly to @nats-io/transport-node. If you use NATS
credentials, pass them through client.authenticator; there is no separate
package-level nkey option.
onConnectError runs only when a connection attempt fails before the first
successful connection. Later disconnects and reconnects are handled by the
underlying NATS client.
import { Injectable } from '@nestjs/common'
import { NatsClient } from '@wisemen/nestjs-nats'
@Injectable()
export class MyService {
constructor (private readonly nats: NatsClient) {}
async notifySomething (): Promise<void> {
await this.nats.publish(
'my.subject',
new TextEncoder().encode(JSON.stringify({ hello: 'world' }))
)
}
}
Use when creating or updating api specific packages in `packages/api/*`, especially for package structure, exports, module wiring, docs, and validation.
Use when implementing or reviewing HTTP integrations inside api specific packages, especially for transport choice, timeout placement, request shaping, and error handling.
Use when configuring a shared OSRM client in NestJS APIs.
Use when configuring transactional mail delivery in NestJS APIs with @wisemen/nestjs-mail.
Use when generating CSVs in APIs.
Use when scanning NestJS providers with DiscoveryService-backed utilities.