debug: fix types for 403 interceptors

This commit is contained in:
Martin Porwoll 2026-02-25 13:13:10 +00:00
parent 26ceccbfb9
commit 36823b2d9f

View file

@ -133,36 +133,30 @@ const dirname = path.dirname(filename)
export default buildConfig({ export default buildConfig({
// DEBUG: Log all API requests that result in 403 // DEBUG: Log all API requests that result in 403
onInit: async (payload) => { onInit: async (payload) => {
const originalFindGlobal = payload.findGlobal.bind(payload) // eslint-disable-next-line @typescript-eslint/no-explicit-any
payload.findGlobal = async (args: Parameters<typeof payload.findGlobal>[0]) => { const origFindGlobal = payload.findGlobal.bind(payload) as any
try { // eslint-disable-next-line @typescript-eslint/no-explicit-any
return await originalFindGlobal(args) ;(payload as any).findGlobal = async (args: any) => {
} catch (err: unknown) { try { return await origFindGlobal(args) } catch (err: any) {
if (err && typeof err === 'object' && 'status' in err && (err as { status: number }).status === 403) { if (err?.status === 403) console.log('[DEBUG:403] Global read FORBIDDEN:', { slug: args.slug, user: args.req?.user?.email || 'no user' })
console.log('[DEBUG:403] Global read FORBIDDEN:', { slug: args.slug, user: args.req?.user?.email || 'no user' })
}
throw err throw err
} }
} }
const originalUpdate = payload.update.bind(payload) // eslint-disable-next-line @typescript-eslint/no-explicit-any
payload.update = async (args: Parameters<typeof payload.update>[0]) => { const origUpdate = payload.update.bind(payload) as any
try { // eslint-disable-next-line @typescript-eslint/no-explicit-any
return await originalUpdate(args) ;(payload as any).update = async (args: any) => {
} catch (err: unknown) { try { return await origUpdate(args) } catch (err: any) {
if (err && typeof err === 'object' && 'status' in err && (err as { status: number }).status === 403) { if (err?.status === 403) console.log('[DEBUG:403] Collection update FORBIDDEN:', { collection: args.collection, id: args.id, user: args.req?.user?.email || 'no user' })
console.log('[DEBUG:403] Collection update FORBIDDEN:', { collection: args.collection, id: args.id, user: args.req?.user?.email || 'no user' })
}
throw err throw err
} }
} }
const originalUpdateGlobal = payload.updateGlobal.bind(payload) // eslint-disable-next-line @typescript-eslint/no-explicit-any
payload.updateGlobal = async (args: Parameters<typeof payload.updateGlobal>[0]) => { const origUpdateGlobal = payload.updateGlobal.bind(payload) as any
try { // eslint-disable-next-line @typescript-eslint/no-explicit-any
return await originalUpdateGlobal(args) ;(payload as any).updateGlobal = async (args: any) => {
} catch (err: unknown) { try { return await origUpdateGlobal(args) } catch (err: any) {
if (err && typeof err === 'object' && 'status' in err && (err as { status: number }).status === 403) { if (err?.status === 403) console.log('[DEBUG:403] Global update FORBIDDEN:', { slug: args.slug, user: args.req?.user?.email || 'no user' })
console.log('[DEBUG:403] Global update FORBIDDEN:', { slug: args.slug, user: args.req?.user?.email || 'no user' })
}
throw err throw err
} }
} }