diff --git a/src/Plugin.ts b/src/Plugin.ts index 52406d5..5a221b6 100644 --- a/src/Plugin.ts +++ b/src/Plugin.ts @@ -125,23 +125,38 @@ export class Plugin extends BasePlugin { this.protectRoutes() } + private buildMetadataRoute(routes: AdminRoute[]) { + const route = routes.find((r) => r.action === 'metadata') + if (route) { + const expressPath = convertToExpressPath(route.path) + const handler = this.getRouteHandler(route) + + if (route.method === 'GET') { + this.router.get(expressPath, handler) + } + } + } + public buildRoutes(): void { const { routes } = AdminRouter this.router.use(formidableMiddleware(this.options.formidableOptions ?? {})) + this.buildMetadataRoute(routes) this.buildAuthenticationRoutes() routes.forEach((route) => { - const expressPath = convertToExpressPath(route.path) - const handler = this.getRouteHandler(route) + if (route.action !== 'metadata') { + const expressPath = convertToExpressPath(route.path) + const handler = this.getRouteHandler(route) - if (route.method === 'GET') { - this.router.get(expressPath, handler) - } + if (route.method === 'GET') { + this.router.get(expressPath, handler) + } - if (route.method === 'POST') { - this.router.post(expressPath, handler) + if (route.method === 'POST') { + this.router.post(expressPath, handler) + } } }) }