77 */
88
99import { inject , named } from 'inversify' ;
10- import { Controller , Get , Post , Put , Delete , RequestParam , RequestBody , Response , Request } from 'inversify-express-utils' ;
10+ import { controller , httpGet , httpPost , httpPut , httpDelete , response , request , requestBody , requestParam } from 'inversify-express-utils' ;
1111import { app } from '../../app' ;
1212import { Types , Targets } from '../../constants' ;
1313import { UserService } from '../services/UserService' ;
@@ -17,42 +17,42 @@ const populateUser = app.IoC.getNamed<interfaces.Middleware>(Types.Middleware, T
1717const authenticate = app . IoC . getNamed < interfaces . Middleware > ( Types . Middleware , Targets . Middleware . AuthenticateMiddleware ) ;
1818
1919
20- @Controller ( '/users' , authenticate . use )
20+ @controller ( '/users' , authenticate . use )
2121export class UserController {
2222
2323 constructor ( @inject ( Types . Service ) @named ( Targets . Service . UserService ) private userService : UserService ) { }
2424
25- @Get ( '/' )
26- public async findAll ( @Response ( ) res : myExpress . Response ) : Promise < any > {
25+ @httpGet ( '/' )
26+ public async findAll ( @response ( ) res : myExpress . Response ) : Promise < any > {
2727 const users = await this . userService . findAll ( ) ;
2828 return res . found ( users . toJSON ( ) ) ;
2929 }
3030
31- @Post ( '/' )
32- public async create ( @Response ( ) res : myExpress . Response , @RequestBody ( ) body : any ) : Promise < any > {
31+ @httpPost ( '/' )
32+ public async create ( @response ( ) res : myExpress . Response , @requestBody ( ) body : any ) : Promise < any > {
3333 const user = await this . userService . create ( body ) ;
3434 return res . created ( user . toJSON ( ) ) ;
3535 }
3636
37- @Get ( '/me' , populateUser . use )
38- public async findMe ( @Request ( ) req : myExpress . Request , @Response ( ) res : myExpress . Response ) : Promise < any > {
37+ @httpGet ( '/me' , populateUser . use )
38+ public async findMe ( @request ( ) req : myExpress . Request , @response ( ) res : myExpress . Response ) : Promise < any > {
3939 return res . found ( req . user ) ;
4040 }
4141
42- @Get ( '/:id' )
43- public async findOne ( @Response ( ) res : myExpress . Response , @RequestParam ( 'id' ) id : string ) : Promise < any > {
42+ @httpGet ( '/:id' )
43+ public async findOne ( @response ( ) res : myExpress . Response , @requestParam ( 'id' ) id : string ) : Promise < any > {
4444 const user = await this . userService . findOne ( parseInt ( id , 10 ) ) ;
4545 return res . found ( user . toJSON ( ) ) ;
4646 }
4747
48- @Put ( '/:id' )
49- public async update ( @Response ( ) res : myExpress . Response , @RequestParam ( 'id' ) id : string , @RequestBody ( ) body : any ) : Promise < any > {
48+ @httpPut ( '/:id' )
49+ public async update ( @response ( ) res : myExpress . Response , @requestParam ( 'id' ) id : string , @requestBody ( ) body : any ) : Promise < any > {
5050 const user = await this . userService . update ( parseInt ( id , 10 ) , body ) ;
5151 return res . updated ( user . toJSON ( ) ) ;
5252 }
5353
54- @Delete ( '/:id' )
55- public async destroy ( @Response ( ) res : myExpress . Response , @RequestParam ( 'id' ) id : string ) : Promise < any > {
54+ @httpDelete ( '/:id' )
55+ public async destroy ( @response ( ) res : myExpress . Response , @requestParam ( 'id' ) id : string ) : Promise < any > {
5656 await this . userService . destroy ( parseInt ( id , 10 ) ) ;
5757 return res . destroyed ( ) ;
5858 }
0 commit comments