Skip to content

feat: api for rating#542

Merged
qwerzl merged 18 commits intoComputerization:nextfrom
RadioNoiseE:next
Mar 26, 2024
Merged

feat: api for rating#542
qwerzl merged 18 commits intoComputerization:nextfrom
RadioNoiseE:next

Conversation

@RadioNoiseE
Copy link

No description provided.

@vercel
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
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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
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