feat: feedback v2

This commit is contained in:
taskylizard 2024-08-25 11:00:20 +00:00
parent d17887ca75
commit 9faa251c86
No known key found for this signature in database
GPG key ID: 1820131ED1A24120
26 changed files with 1042 additions and 419 deletions

View file

@ -5,12 +5,33 @@ import {
} from '../../docs/.vitepress/types/Feedback'
export default defineEventHandler(async (event) => {
const { message, page, type } = await readValidatedBody(
const { message, page, type, heading } = await readValidatedBody(
event,
FeedbackSchema.parseAsync
)
const env = useRuntimeConfig(event)
const fields = [
{
name: 'Page',
value: page,
inline: true
},
{
name: 'Message',
value: message,
inline: false
}
]
if (heading) {
fields.push({
name: 'Section',
value: heading,
inline: true
})
}
// FIXME: somehow this is not working, but it worked before
// const path = 'feedback'
//
@ -21,9 +42,6 @@ export default defineEventHandler(async (event) => {
// })
// }
let description = `${message}\n\n`
if (page) description += `**Page:** \`${page}\``
await fetcher()
.post(env.WEBHOOK_URL, {
username: 'Feedback',
@ -33,7 +51,7 @@ export default defineEventHandler(async (event) => {
{
color: 3447003,
title: getFeedbackOption(type).label,
description
fields
}
]
})

3
api/tsconfig.json Normal file
View file

@ -0,0 +1,3 @@
{
"extends": "../.nitro/types/tsconfig.json"
}