Skip to content

Conversation

boazpoolman
Copy link
Contributor

What does it do?

It updates the format for the route files which are generated from the init command.

Old format:

server/src/routes/
├── index.ts
├── content-api.ts
└── admin.ts

New format:

server/src/routes/
├── index.ts
├── content-api/index.ts
└── admin/index.ts

Why is it needed?

This change is needed to allow the use of route factories in plugins. By creating this nested structure we allow the user to create files like this:

server/src/routes/content-api/page.ts:

/**
 * page router
 */

import { factories } from '@strapi/strapi';

export default factories.createCoreRouter('plugin::my-plugin.page');

These core routes can then be used in the index file like this:

server/src/routes/content-api/index.ts:

import page from './page';

export default () => ({
  type: 'content-api',
  routes: [
    ...page.routes,
  ],
});

How to test it?

Using the core routers is out of the scope of this PR. This PR simply updates the structure to allow this at a later stage. So to test this PR you should test if the new format as described above still works as expected.

Related issue(s)/PR(s)

Possibly related to #90

Copy link

changeset-bot bot commented Oct 9, 2025

🦋 Changeset detected

Latest commit: 0354cdb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@strapi/sdk-plugin Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@boazpoolman boazpoolman force-pushed the feature/update-generated-route-files branch from 148aec1 to 0354cdb Compare October 9, 2025 16:25
@hanpaine hanpaine requested a review from jhoward1994 October 9, 2025 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant