Skip to content

Commit

Permalink
feat: add different type for Publish and Subscribe apis
Browse files Browse the repository at this point in the history
  • Loading branch information
playerx committed May 2, 2024
1 parent 0f70189 commit e929b51
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/nats.transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type Authenticatior =
*/

// deno-lint-ignore ban-types
export class NatsTransport<TApi, TContext = {}> implements Transport {
export class NatsTransport<TPublishApi, TSubscribeApi, TContext = {}> implements Transport {
get state(): TransportState {
return this._state
}
Expand Down Expand Up @@ -400,7 +400,7 @@ export class NatsTransport<TApi, TContext = {}> implements Transport {
*
* @returns dispose function
*/
async subscribeEvents<TOverrideApi = TApi>(
async subscribeEvents<TOverrideApi = TSubscribeApi>(
handlerMap: Map1<
TOverrideApi,
TContext | TransportContext<MessageMetadata>
Expand Down Expand Up @@ -436,9 +436,9 @@ export class NatsTransport<TApi, TContext = {}> implements Transport {
}
}

publish<K extends keyof TApi & string>(
publish<K extends keyof TPublishApi & string>(
route: K,
payload: TApi[K],
payload: TPublishApi[K],
options: PublishOptions<MessageMetadata> = {},
): Promise<void> {
if (!this.nc) {
Expand Down Expand Up @@ -477,9 +477,9 @@ export class NatsTransport<TApi, TContext = {}> implements Transport {
return Promise.resolve()
}

async execute<K extends keyof TApi & string, TResult>(
async execute<K extends keyof TPublishApi & string, TResult>(
route: K,
payload: TApi[K],
payload: TPublishApi[K],
options: ExecuteOptions<MessageMetadata> = {},
): Promise<TResult> {
if (!this.nc) {
Expand Down

0 comments on commit e929b51

Please sign in to comment.