Created
March 4, 2019 14:48
-
-
Save saurabhpati/bcc1287d54ef99e416b456e9c88c2926 to your computer and use it in GitHub Desktop.
User Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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