fix: add ComponentLoader for @adminjs/upload v4 compatibility
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f4ac81dac3
commit
39f7db84fb
@ -1,4 +1,4 @@
|
|||||||
import AdminJS from 'adminjs'
|
import AdminJS, { ComponentLoader } from 'adminjs'
|
||||||
import AdminJSFastify from '@adminjs/fastify'
|
import AdminJSFastify from '@adminjs/fastify'
|
||||||
import { Database, Resource, getModelByName } from '@adminjs/prisma'
|
import { Database, Resource, getModelByName } from '@adminjs/prisma'
|
||||||
import uploadFeature from '@adminjs/upload'
|
import uploadFeature from '@adminjs/upload'
|
||||||
@ -10,6 +10,8 @@ import { prisma } from './src/lib/db.mjs'
|
|||||||
|
|
||||||
AdminJS.registerAdapter({ Database, Resource })
|
AdminJS.registerAdapter({ Database, Resource })
|
||||||
|
|
||||||
|
const componentLoader = new ComponentLoader()
|
||||||
|
|
||||||
const stripe = process.env.STRIPE_SECRET_KEY
|
const stripe = process.env.STRIPE_SECRET_KEY
|
||||||
? new Stripe(process.env.STRIPE_SECRET_KEY)
|
? new Stripe(process.env.STRIPE_SECRET_KEY)
|
||||||
: null
|
: null
|
||||||
@ -183,6 +185,7 @@ async function autoComputeFields(response) {
|
|||||||
export async function setupAdmin(app) {
|
export async function setupAdmin(app) {
|
||||||
const admin = new AdminJS({
|
const admin = new AdminJS({
|
||||||
rootPath: '/admin',
|
rootPath: '/admin',
|
||||||
|
componentLoader,
|
||||||
resources: [
|
resources: [
|
||||||
{
|
{
|
||||||
resource: { model: getModelByName('Product'), client: prisma },
|
resource: { model: getModelByName('Product'), client: prisma },
|
||||||
@ -242,6 +245,7 @@ export async function setupAdmin(app) {
|
|||||||
},
|
},
|
||||||
features: [
|
features: [
|
||||||
uploadFeature({
|
uploadFeature({
|
||||||
|
componentLoader,
|
||||||
provider: {
|
provider: {
|
||||||
local: { bucket: UPLOADS_DIR },
|
local: { bucket: UPLOADS_DIR },
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user