import express , { Request , Response } from 'express' ; import { asyncWrapper } from '../utils/asyncWrapper' ; import { UsersService } from '../../domain/users/usersService' ; const router = express . Router ( ) ; export function userRoute ( userService ) { router . get ( '/' , asyncWrapper ( async ( _ , res ) => { const users = await userService . getAllUsers ( ) ; res . json ( users ) ; } ) ) ; router . post ( '/' , asyncWrapper ( async ( req , res ) => { const { firstName , lastName , age } = req . body ; const user = await userService . createUser ( firstName , lastName , age ) ; res . json ( user ) ; } ) ) ; return router ; }