Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: api for rating #542

Merged
merged 18 commits into from
Mar 26, 2024
Merged

feat: api for rating #542

merged 18 commits into from
Mar 26, 2024

Conversation

RadioNoiseE
Copy link
Contributor

No description provided.

Copy link

vercel bot commented Mar 22, 2024

@RadioNoiseE is attempting to deploy a commit to the qwerzl Team on Vercel.

A member of the Team first needs to authorize it.

@qwerzl
Copy link
Collaborator

qwerzl commented Mar 22, 2024

Before writing into the database, you should check if there's any record of a same user, same scope and same club. Return 403 if there is already one.

@RadioNoiseE RadioNoiseE changed the title feat(api): creat a new rating feat(api): api for rating Mar 24, 2024
@qwerzl qwerzl changed the title feat(api): api for rating feat: api for rating Mar 25, 2024
club: z.string(),
date: z.string().datetime(),
score: z.number().lte(5),
comment: z.string(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

max 100

date: z.string().datetime(),
score: z.number().lte(5),
comment: z.string(),
scope: z.string(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

length(5)

return
}

const requestBody = await readValidatedBody(event, body => requestSchema.safeParse(body))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just use requestSchema.parse(), so it will automatically return a validation error if validation is not success.

}

const requestBody = await readValidatedBody(event, body => requestSchema.safeParse(body))
if (requestBody.success) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

So you don't need this if here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, check if requestSchema.scope equals to the current scope. If not, return 403.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Change rateable to available

@qwerzl qwerzl merged commit 3db73f6 into Computerization:next Mar 26, 2024
2 of 4 checks passed
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