All quizzesMedium
Advanced Routing
Preview — 3 of 10 questions
You need every response from a handler to include Cache-Control: no-store. Which decorator sets a static response header without touching @Res()?
javascript
import { Controller, Get, Header } from '@nestjs/common';
@Controller('reports')
export class ReportsController {
@Get()
@Header('Cache-Control', 'no-store')
generate(): { ok: boolean } {
return { ok: true };
}
}A@SetHeader('Cache-Control', 'no-store')
B@Meta('Cache-Control', 'no-store')
C@ResponseHeader('Cache-Control', 'no-store')
D@Header('Cache-Control', 'no-store')
Which @Get() path matches any sub-path under /files, such as /files/a/b/c?
javascript
import { Controller, Get, Param } from '@nestjs/common';
@Controller()
export class FilesController {
@Get('files/*')
serve(@Param() params: Record<string, string>): string {
return 'serving wildcard path';
}
}A@Get('files/:all')
B@Get('files/**')
C@Get('files/*')
D@Get('files/[...]')
You want a controller to handle requests only on admin.example.com. Which configuration achieves sub-domain routing?
javascript
import { Controller, Get, HostParam } from '@nestjs/common';
@Controller({ host: ':account.example.com' })
export class AccountController {
@Get()
index(@HostParam('account') account: string): string {
return `tenant: ${account}`;
}
}A@Controller({ subdomain: 'admin' })
B@Controller('admin.example.com')
C@Host('admin.example.com') on the class
D@Controller({ host: 'admin.example.com' })
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.