Skip to content

Instantly share code, notes, and snippets.

@MrCube42
Created March 28, 2020 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MrCube42/006e11a85fa110788cbb00c52dbb533c to your computer and use it in GitHub Desktop.
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.
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