-
-
Save MrCube42/006e11a85fa110788cbb00c52dbb533c to your computer and use it in GitHub Desktop.
Grundgerüst der ersten zwei GET-Routen zur Verarbeitung der Routen /companions und /companions/:id. An Stelle von Promises, können auch Observables verwendet werden.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Companion, CompanionDetails } from '@interfaces'; | |
import { Controller, Get, Param } from '@nestjs/common'; | |
import { ApiOperation, ApiResponse, ApiUseTags } from '@nestjs/swagger'; | |
import { CompanionsService } from '../../services/companions/companions.service'; | |
@Controller('companions') | |
export class CompanionsController { | |
@Get() | |
async getAll(): Promise<Companion[]> { // Hier kann man ebenfalls Companion[] oder Observable<Companion[]> zurückliefern. | |
// ... | |
} | |
@Get(':id') | |
async getCompanionDetails(@Param('id') id: string): Promise<CompanionDetails> { | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment