Interceptors

์ผ๋ฐ˜ ์ธํ„ฐ์…‰ํ„ฐ์™€ ๋งˆ์ดํฌ๋กœ ์„œ๋น„์Šค ์ธํ„ฐ์…‰ํ„ฐ ์‚ฌ์ด์—๋Š” ์ฐจ์ด๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ์€ ์ˆ˜๋™์œผ๋กœ ์ธ์Šคํ„ด์Šคํ™”๋œ ๋ฉ”์†Œ๋“œ ๋ฒ”์œ„ ์ธํ„ฐ์…‰ํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค (ํด๋ž˜์Šค ๋ฒ”์œ„๋„ ์ž‘๋™ ํ•จ).

@@filename()
@UseInterceptors(new TransformInterceptor())
@MessagePattern({ cmd: 'sum' })
accumulate(data: number[]): number {
  return (data || []).reduce((a, b) => a + b);
}

Last updated

Was this helpful?