Junior — Middle
How many API endpoints have you implemented using NestJS?
sobes.tech AI
Answer from AI
The number of implemented API endpoints in NestJS depends on the specific project and requirements. Usually, in small projects, you can implement from a few to dozens of endpoints covering basic CRUD operations and business logic.
NestJS allows easy creation of controllers and services for handling requests, for example:
import { Controller, Get, Post, Body, Param } from '@nestjs/common';
@Controller('users')
export class UsersController {
@Get()
findAll() {
// returns a list of users
}
@Get(':id')
findOne(@Param('id') id: string) {
// returns a user by id
}
@Post()
create(@Body() createUserDto) {
// creates a new user
}
}
Thus, the number of endpoints can vary, but it is important to be able to structure the code and maintain it in a scalable way.