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.

Severity#

error. This rule is enabled in the recommended preset.

What it Targets#

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:

src/api/store/products/handlers.ts
1export const GET = async (req, res) => {2  res.json({})3}

Instead, export the handler from a route file:

src/api/store/products/route.ts
1export const GET = async (req, res) => {2  res.json({})3}

Why it's Important#

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.

Fixable#

This rule isn't auto-fixable.

Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵