fix: add ComponentLoader for @adminjs/upload v4 compatibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ordinarthur 2026-03-20 23:42:31 +01:00
parent f4ac81dac3
commit 39f7db84fb

View File

@ -1,4 +1,4 @@
import AdminJS from 'adminjs'
import AdminJS, { ComponentLoader } from 'adminjs'
import AdminJSFastify from '@adminjs/fastify'
import { Database, Resource, getModelByName } from '@adminjs/prisma'
import uploadFeature from '@adminjs/upload'
@ -10,6 +10,8 @@ import { prisma } from './src/lib/db.mjs'
AdminJS.registerAdapter({ Database, Resource })
const componentLoader = new ComponentLoader()
const stripe = process.env.STRIPE_SECRET_KEY
? new Stripe(process.env.STRIPE_SECRET_KEY)
: null
@ -183,6 +185,7 @@ async function autoComputeFields(response) {
export async function setupAdmin(app) {
const admin = new AdminJS({
rootPath: '/admin',
componentLoader,
resources: [
{
resource: { model: getModelByName('Product'), client: prisma },
@ -242,6 +245,7 @@ export async function setupAdmin(app) {
},
features: [
uploadFeature({
componentLoader,
provider: {
local: { bucket: UPLOADS_DIR },
},