Hello everyone, welcome to Learn Tech Tips I am Zidane, (my nickname: ιΈ‘θ)
Good day to you. This series will share with you how to build a web application with server, client side, and you will learn many useful things on this project.
As the title you will learn how to
- Use NestJs build a server connect with a MongoDB (use JWT for authentication, how to query on server, create schema, entity, controller, service)
- Use NextJS build a client side with TailwindCss fast build component, Zustand state management (easy manage state), Axios Request API.
After check all this full series, I believe you will have a mindset how to build a website app from backend to frontend. You will understand how to become a full stack developer through this todo web app
Full Tutorial "TodoList Apps with NextJS Zustand" Axios TailwindCSS React NestJS Mongoose JWT (Day 5)
On day 5: We will focus on how to work with @Body, @Param, @Query
Let double check src/todos/todos.controller.ts
we will action on search function, and here is controller of todos
UseGuards(JwtAuthGuard)
@Get('search')
public async search(
@Request() req: any,
@Query('limit') limit: number,
@Query('page') page: number,
@Query('job') job: string,
@Query('type') type: number,
@Query('status') status: string
) {
return await this.todosService.search(req.user.params.username, limit, page, job, type, status);
}
We're using @Query on search query
Here is the @Param example
@UseGuards(JwtAuthGuard)
@Patch(':id')
public async changeStatusTodo(@Param('id') id: string) {
return await this.todosService.changeStatusTodo(id);
}
Here is the @Body example
@UseGuards(JwtAuthGuard)
@Post()
public async create(@Request() req: any, @Body() todosDto: TodosDto) {
return await this.todosService.create(todosDto, req.user.params.username);
}