import { controller , httpGet , httpPost , httpPut , httpDelete } from 'inversify-express-utils' ; import { inject } from 'inversify' ; import { Request } from 'express' ; import { User } from '../models/user' ; import { UserService } from '../service/user' ; import TYPES from '../constant/types' ; @ controller ( '/user' ) export class UserController { constructor ( @ inject ( TYPES . UserService ) private userService ) { } @ httpGet ( '/' ) public getUsers ( ) { return this . userService . getUsers ( ) ; } @ httpGet ( '/:id' ) public getUser ( request ) { return this . userService . getUser ( request . params . id ) ; } @ httpPost ( '/' ) public newUser ( request ) { return this . userService . newUser ( request . body ) ; } @ httpPut ( '/:id' ) public updateUser ( request ) { return this . userService . updateUser ( request . params . id , request . body ) ; } @ httpDelete ( '/:id' ) public deleteUser ( request ) { return this . userService . deleteUser ( request . params . id ) ; } }