/
githubmirror
/
nest
Обзор
Документация
Войти
/
githubmirror
/
nest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
integration/hello-world/src/host/host.controller.ts
37 строк
1 KB
Kamil Myśliwiec
style: address integration tests lint errors
26 ноя 2024, 11:39
Не верифицирован
26 ноя 2024, 11:39
236b633
Код
Авторство
О чём код?
import { Controller, Get, Header, HostParam, Param } from '@nestjs/common'; import { Observable, of } from 'rxjs'; import { HostService } from './host.service'; import { UserByIdPipe } from './users/user-by-id.pipe'; @Controller({ path: 'host', host: ':tenant.example.com', }) export class HostController { constructor(private readonly hostService: HostService) {} @Get() @Header('Authorization', 'Bearer') greeting(@HostParam('tenant') tenant: string): string { return `${this.hostService.greeting()} tenant=${tenant}`; } @Get('async') async asyncGreeting(@HostParam('tenant') tenant: string): Promise<string> { return `${this.hostService.greeting()} tenant=${tenant}`; } @Get('stream') streamGreeting(@HostParam('tenant') tenant: string): Observable<string> { return of(`${this.hostService.greeting()} tenant=${tenant}`); } @Get('local-pipe/:id') localPipe( @Param('id', UserByIdPipe) user: any, @HostParam('tenant') tenant: string, ): any { return { ...user, tenant }; } }