Skip to content

NestJS #590

Answered by TatyOko28
Mercure28 asked this question in Q&A
Discussion options

You must be logged in to vote

In NestJS, a controller is a class that handles HTTP routes. We use the decorator @controller()to define a controller and @get(), @post(), etc. to define routes.

Example of a basic controller :

import { Controller, Get } from '@nestjs/common';

@Controller('users') // Toutes les routes seront sous /users
export class UsersController {
  @Get()
  findAll() {
    return ['User1', 'User2', 'User3'];
  }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Mercure28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants