All quizzesHard
Versioning & Streaming — Series 2
Preview — 3 of 10 questions
How does this differ from VersioningType.URI?
javascript
app.enableVersioning({
type: VersioningType.HEADER,
header: 'X-API-Version',
});
@Controller('cats')
export class CatsControllerV2 {
@Version('2')
@Get()
findAll() { /* ... */ }
}AHeader versioning supports only integer versions, while URI versioning accepts arbitrary strings
BHeader versioning applies per controller, whereas URI versioning can only be set globally
CThere is no functional difference; the two names are aliases
DThe version is selected by a request header rather than a URL segment — so the resource keeps one canonical URL, at the cost of versions being invisible in logs, bookmarks and browser address bars
What does VERSION_NEUTRAL do?
javascript
@Controller({ path: 'health', version: VERSION_NEUTRAL })
export class HealthController {
@Get() check() { return { status: 'ok' }; }
}AIt registers the route under every version currently declared anywhere in the application
BIt disables versioning globally as a side effect
CIt makes the route match regardless of the requested version — including requests that specify no version at all
DIt makes the route reachable only when the client omits the version entirely
What does the array form achieve?
javascript
@Controller({ path: 'cats' })
export class CatsController {
@Version(['1', '2'])
@Get()
findAll() { /* ... */ }
@Version('3')
@Get()
findAllV3() { /* ... */ }
}AIt serves version 1 and redirects version 2 to it
BThe same handler answers both 1 and 2, while 3 is routed to the newer method — the usual way to keep an unchanged endpoint alive across a version bump without duplicating code
CIt creates two separate instances of the controller, one per version
DIt is invalid — @Version() accepts a single string
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.