import * as express from 'express' import { Request, Response } from 'express' import ControllerBase from '../interfaces/ControllerBase' import {UserService} from '../service/UserService' import { User } from '../model/User' import { ApiError } from '../errors/error' export class UserController implements ControllerBase { public path = '/user' public router = express.Router() public userService: UserService constructor() { this.initRoutes() this.userService = new UserService() } public initRoutes() { this.router.get(this.path, this.get) this.router.post(this.path,this.post) } post = (req: Request, res: Response) => { if(Object.keys(req.body).length !== 0){ const user: User = new User() this.userService.createUser(user,res) } res.status(400).send({message: 'Invalid request body'}) } get = (req: Request, res: Response) => { const user: User = new User() this.userService.getUser(user,res) } }