-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: api for rating #542
Conversation
@RadioNoiseE is attempting to deploy a commit to the qwerzl Team on Vercel. A member of the Team first needs to authorize it. |
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. |
server/api/club/rating/new.post.ts
Outdated
club: z.string(), | ||
date: z.string().datetime(), | ||
score: z.number().lte(5), | ||
comment: z.string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max 100
server/api/club/rating/new.post.ts
Outdated
date: z.string().datetime(), | ||
score: z.number().lte(5), | ||
comment: z.string(), | ||
scope: z.string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
length(5)
server/api/club/rating/new.post.ts
Outdated
return | ||
} | ||
|
||
const requestBody = await readValidatedBody(event, body => requestSchema.safeParse(body)) |
There was a problem hiding this comment.
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.
server/api/club/rating/new.post.ts
Outdated
} | ||
|
||
const requestBody = await readValidatedBody(event, body => requestSchema.safeParse(body)) | ||
if (requestBody.success) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change rateable to available
No description provided.