Skip to content

Commit

Permalink
docs: Add Payload & Ctx to NestJS readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenh committed Jan 28, 2024
1 parent 80a0353 commit 8dc2b5e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion NESTJS.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ For the client we simply pass the **client** interface to the `client.getService
```typescript
// ...
import { HeroById, Hero, HeroServiceController, VillainById, Villain, HeroServiceControllerMethods } from '../hero';
import { Ctx, Payload } from '@nestjs/microservices';

@Controller('hero')
// Generated decorator that applies all the @GrpcMethod and @GrpcStreamMethod to the right methods
Expand All @@ -61,7 +62,10 @@ export class HeroController implements HeroServiceController {
return this.heroes.find(({ id }) => id === data.id)!;
}

async findOneVillain(data: VillainById): Promise<Villain> {
async findOneVillain(
@Payload() data: VillainById,
@Ctx() metadata: Metadata,
): Promise<Villain> {
return this.villains.find(({ id }) => id === data.id)!;
}

Expand Down

0 comments on commit 8dc2b5e

Please sign in to comment.