Skip to content

feat: add api to get all projects#6

Open
sahsisunny wants to merge 1 commit intomainfrom
get-projects-api
Open

feat: add api to get all projects#6
sahsisunny wants to merge 1 commit intomainfrom
get-projects-api

Conversation

@sahsisunny
Copy link
Contributor

@sahsisunny sahsisunny commented Jan 19, 2025

image

if (error instanceof Error) {
res.status(500).json({ error: error.message });
} else {
res.status(500).json({ error: 'An unknown error occurred' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'An unknown error occurred' lets define a standard constant and use it here?

Comment on lines +4 to +16
export const checkProjectAccess = async (
project_id: string,
user_id: string,
): Promise<boolean> => {
const prisma = new PrismaClient();
const project = await prisma.project.findFirst({
where: {
id: project_id,
created_by: user_id,
},
});
return project !== null;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be split into two one model function and one middleware function the checking part middleware will do and model function will be only responsible for fetching the data

Comment on lines +22 to +28
id: project.id,
name: project.name,
description: project.description,
logo: project.logo,
created_by: project.created_by,
created_at: project.created_at.toISOString(),
updated_at: project.updated_at.toISOString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can write utils fo transforming this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants