UNPKG

@initbit/nestjs-jetstream

Version:
54 lines (53 loc) 1.69 kB
import { BaseRpcContext } from "@nestjs/microservices/ctx-host/base-rpc.context"; import { JsMsg, Msg, MsgHdrs } from "nats"; type NatsContextArgs = [JsMsg | Msg, Record<string, any> | undefined]; export declare class NatsContext extends BaseRpcContext<NatsContextArgs> { private extras?; constructor(args: NatsContextArgs); /** * Returns message headers (if exist). */ getHeaders(): MsgHdrs | undefined; /** * Returns the message object. */ getMessage(): JsMsg | Msg; /** * Returns the name of the subject. */ getSubject(): string; /** * Checks if the message is a JetStream message. */ isJetStream(): boolean; /** * Acknowledges the message (JetStream only). * @throws Error if the message is not a JetStream message */ ack(): void; /** * Negative acknowledges the message, indicating it should be redelivered (JetStream only). * @throws Error if the message is not a JetStream message */ nack(): void; /** * Terminates the message, indicating it should not be redelivered (JetStream only). * @throws Error if the message is not a JetStream message */ term(): void; /** * Marks the message as being worked on, extending the ack wait time (JetStream only). * @throws Error if the message is not a JetStream message */ working(): void; /** * Returns the JetStream message metadata (JetStream only). * @throws Error if the message is not a JetStream message */ getMetadata(): any; /** * Returns the extras object. */ getExtras(): Record<string, any> | undefined; } export {};