Last active
October 23, 2019 00:41
-
-
Save adsonrocha/02586b7e16bf6a887d71caf6bde4fbb6 to your computer and use it in GitHub Desktop.
User controller to call service with mongoose model injected
This file contains hidden or 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 { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common'; | |
import { UserService } from './user.service'; | |
import { User } from './user.model'; | |
@Controller('user') | |
export class UserController { | |
constructor(private service: UserService) { | |
} | |
@Get('findById/:id') | |
get(@Param() params) { | |
return this.service.findById(params.id); | |
} | |
@Post('create') | |
create(@Body() user: User) { | |
return this.service.create(user); | |
} | |
@Put('update') | |
update(@Body() user: User) { | |
return this.service.update(user); | |
} | |
@Delete('delete/:id') | |
remove(@Param() params) { | |
return this.service.remove(params.id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment