feat(aep): carte AEP — push Gitea 2026-04-28
This commit is contained in:
22
server/api/comment/[orgId].get.ts
Normal file
22
server/api/comment/[orgId].get.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* GET /api/comment/[orgId]
|
||||
* Retourne les commentaires publiés (published=true) pour une fiche.
|
||||
* Triés par submitted_at ASC (chronologique).
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const config = useRuntimeConfig()
|
||||
const orgId = getRouterParam(event, 'orgId')
|
||||
|
||||
if (!orgId || isNaN(Number(orgId))) {
|
||||
throw createError({ statusCode: 400, message: 'Identifiant invalide' })
|
||||
}
|
||||
|
||||
const tableId = config.commentTableId
|
||||
const url = `${config.nocodbUrl}/api/v2/tables/${tableId}/records?where=(orga_id,eq,${orgId})~and(published,eq,true)&sort=submitted_at&limit=50`
|
||||
|
||||
const data: any = await $fetch(url, {
|
||||
headers: { 'xc-token': config.nocodbToken },
|
||||
}).catch(() => ({ list: [] }))
|
||||
|
||||
return { list: data?.list ?? [] }
|
||||
})
|
||||
Reference in New Issue
Block a user