Skip to content

Instantly share code, notes, and snippets.

@saurabhpati
Created March 4, 2019 14:48
Show Gist options
  • Save saurabhpati/bcc1287d54ef99e416b456e9c88c2926 to your computer and use it in GitHub Desktop.
Save saurabhpati/bcc1287d54ef99e416b456e9c88c2926 to your computer and use it in GitHub Desktop.
User Controller
import { Controller, Post, Get, Body, Query, Put, Delete } from '@nestjs/common';
import { UserService } from './user.service';
import { CreateUserDto } from './dtos/create.user.dto';
import { UpdateUserDto } from './dtos/update.user.dto';
@Controller('User')
export class UserController {
constructor(private readonly userService: UserService) {
}
@Post()
register(@Body()userDto: CreateUserDto) {
return this.userService.create(userDto);
}
@Get()
getAll() {
return this.userService.getAll();
}
@Get()
get(@Query()username: string) {
return this.userService.get(username);
}
@Put()
update(@Body()updateDto: UpdateUserDto) {
return this.userService.update(updateDto);
}
@Delete()
delete(id: number) {
return this.userService.delete(id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment