mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 16:23:06 +10:00
32 lines
596 B
TypeScript
32 lines
596 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
|
|
|
export interface GetUserByIdOptions {
|
|
id: number;
|
|
}
|
|
|
|
export const getUserById = async ({ id }: GetUserByIdOptions) => {
|
|
const user = await prisma.user.findFirst({
|
|
where: {
|
|
id,
|
|
},
|
|
select: {
|
|
id: true,
|
|
name: true,
|
|
email: true,
|
|
emailVerified: true,
|
|
roles: true,
|
|
disabled: true,
|
|
twoFactorEnabled: true,
|
|
signature: true,
|
|
},
|
|
});
|
|
|
|
if (!user) {
|
|
throw new AppError(AppErrorCode.NOT_FOUND);
|
|
}
|
|
|
|
return user;
|
|
};
|