Skip to content

Commit

Permalink
creation of profile wip
Browse files Browse the repository at this point in the history
  • Loading branch information
arogya01 committed Sep 17, 2024
1 parent 10087b1 commit 37cae1b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/modules/user/user.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ async function userRoutes(server: FastifyInstance){
}
}
}, signupHandler);
server.get("/profile",{
schema: {
body: $ref("getUserProfileSchema"),
response: {
200: $ref("getUserProfileRespSchema")
}
}
}, getUsersHandler);
server.get("/users", getUsersHandler);
}

Expand Down
15 changes: 15 additions & 0 deletions src/modules/user/user.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ const createUserRespSchema = z.object({
...userCore,
});

const getUserProfileSchema = z.object({
accessToken: z.string(),
});

const getUserProfileRespSchema = z.object({
id: z.number(),
userName: z.string(),
email: z.string(),
phoneNumber: z.string(),
bio: z.string().nullable(),
image: z.string().nullable(),
});

export type CreateUserInput = z.infer<typeof createUserSchema>;

export type LoginUserInput = z.infer<typeof loginUserSchema>;
Expand All @@ -54,4 +67,6 @@ export const { schemas: userSchemas, $ref } = buildJsonSchemas({
loginUserSchema,
createUserRespSchema,
loginRespSchema,
getUserProfileSchema,
getUserProfileRespSchema,
});
17 changes: 17 additions & 0 deletions src/modules/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ export const createUser = async (requestBody: CreateUserInput) => {

export const verifyPassword = async () => {};

export const fetchUserByUserId = async (userId:number) => {
console.log('fetching user by id', userId);
const userProfile = await prisma.profile.findUnique({
where: {
userId : userId
},
include:{
user:true
}
});

console.log('userProifle,', userProfile);

return userProfile;

}

export const checkExistingUser = async (email: string) => {
console.log("check for existing user");

Expand Down

0 comments on commit 37cae1b

Please sign in to comment.