breaking: remove loading middlewares file in favor of routes-config files (#8274)

This commit is contained in:
Harminder Virk authored and GitHub committed 2024-07-25 12:53:35 +05:30
1 parent 13855e9167
commit 0bd46c97b7
5 files changed
+99 -95

No files matched your search

@@ -32,8 +32,16 @@ export function defineRoutesConfig<
next: MedusaNextFunction
) => any)[]
}
>(routes: Route[]): MiddlewaresConfig {
>(
config:
| Route[]
| { routes?: Route[]; errorHandler?: MiddlewaresConfig["errorHandler"] }
): MiddlewaresConfig {
const routes = Array.isArray(config) ? config : config.routes || []
const errorHandler = Array.isArray(config) ? undefined : config.errorHandler
return {
errorHandler,
routes: routes.map((route) => {
const { middlewares, extendedValidators, ...rest } = route
const customMiddleware: MedusaRequestHandler[] = []