Skip to content

nestjs-architects/typed-cqrs

Repository files navigation

@nestjs-architects/typed-cqrs

version downloads

Tired of hand-typing types for NestJS CQRS package? We got you covered!

⚠️ This library is now deprecated!

All features provided by @nestjs-architects/typed-cqrs are now available natively in @nestjs/cqrs starting from NestJS 11.

This library will no longer be maintained or developed, but it will still work with NestJS@11 and old versions.

Migration Guide

Migrating to @nestjs/cqrs is simple:

  • Replace imports from @nestjs-architects/typed-cqrs to @nestjs/cqrs.
  • Drop Inferred from IInferredQueryHandler and IInferredCommandHandlerIQueryHandler and ICommandHandler now support its extensions.
  • Command, Query, CommandResult, and QueryResult are already included in @nestjs/cqrs.
  • A quick find & replace in your codebase is all you need!

Usage (before NestJS@11)

First install base @nestjs/cqrs package.

$ npm i @nestjs/cqrs

All you need to do, is to extend your query with type of expected response.

import { Query } from '@nestjs-architects/typed-cqrs';

export class GetProfileQuery extends Query<ResultType> {}

Profit

Now, when implementing handler, you get all type completion & safety!

showcase-handler

import { IInferredQueryHandler, QueryHandler } from '@nestjs/cqrs';

@QueryHandler(GetProfileQuery)
export class GetProfileHandler implements IInferredQueryHandler<GetProfileQuery> {}

As well as, results are correctly typed as well! showcase-handler

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published