www/apps/resources/app/lint/rules/route-file-naming/page.mdx
export const metadata = {
title: route-file-naming - ESLint plugin rules,
}
This rule requires API route handlers to be exported from a route.ts or route.js file under src/api.
error. This rule is enabled in the recommended preset.
This rule targets files in your project's src/api directory. It reports HTTP method handlers exported from a file that isn't named route.ts or route.js, and route files that export no HTTP method handler.
The following code is reported by the rule:
export const GET = async (req, res) => {
res.json({})
}
Instead, export the handler from a route file:
export const GET = async (req, res) => {
res.json({})
}
Medusa only registers HTTP method handlers exported from route.ts or route.js files. Handlers placed in other files are never reached, so the route won't work as expected.
Learn more in the API Routes documentation.
This rule isn't auto-fixable.