import { Request , Response , NextFunction } from 'express' ; import { getRepository } from 'typeorm' ; import { User } from 'typeorm/entities/users/User' ; import { CustomError } from 'utils/response/custom-error/CustomError' ; export const list = async ( req , res , next ) => { const userRepository = getRepository ( User ) ; try { const users = await userRepository . find ( { select : [ 'id' , 'username' , 'name' , 'email' , 'role' , 'language' , 'created_at' , 'updated_at' ] , } ) ; res . customSuccess ( 200 , 'List of users.' , users ) ; } catch ( err ) { const customError = new CustomError ( 400 , 'Raw' , `Can't retrieve list of users.` , null , err ) ; return next ( customError ) ; } } ;