Files
the-biergarten-app/src/services/users/User/findUserById.ts
Aaron William Po fd641c36ab Refactor: begin reorganizing services dir.
- Renamed files and directories to reflect the new structure
- Moved comment-related services to the 'comments' directory
- Moved image-related services to the 'images' directory
- Moved like-related services to the 'likes' directory
- Moved post-related services to the 'posts' directory
- Moved user-related services to the 'users' directory
2023-12-10 14:15:31 -05:00

38 lines
848 B
TypeScript

import DBClient from '@/prisma/DBClient';
import { z } from 'zod';
import GetUserSchema from './schema/GetUserSchema';
const findUserById = async (id: string) => {
const user: z.infer<typeof GetUserSchema> | null =
await DBClient.instance.user.findUnique({
where: { id },
select: {
id: true,
username: true,
email: true,
firstName: true,
lastName: true,
dateOfBirth: true,
createdAt: true,
accountIsVerified: true,
updatedAt: true,
role: true,
userAvatar: {
select: {
path: true,
alt: true,
caption: true,
createdAt: true,
id: true,
updatedAt: true,
},
},
bio: true,
},
});
return user;
};
export default findUserById;