Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cyan-beds-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@strapi/sdk-plugin': minor
---

refactor: update the routes folder format for the init command
66 changes: 34 additions & 32 deletions src/cli/commands/plugin/init/files/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,32 @@ const TYPESCRIPT = (pluginName: string): TemplateFile[] => [
`,
},
{
name: 'server/src/routes/content-api.ts',
name: 'server/src/routes/content-api/index.ts',
contents: outdent`
export default [
{
method: 'GET',
path: '/',
// name of the controller file & the method.
handler: 'controller.index',
config: {
policies: [],
},
},
];
export default () => ({
type: 'content-api',
routes: [],
});
`,
},
{
name: 'server/src/routes/admin/index.ts',
contents: outdent`
export default () => ({
type: 'admin',
routes: [],
});
`,
},
{
name: 'server/src/routes/index.ts',
contents: outdent`
import contentAPIRoutes from './content-api';
import adminAPIRoutes from './admin';

const routes = {
'content-api': {
type: 'content-api',
routes: contentAPIRoutes,
},
'content-api': contentAPIRoutes,
admin: adminAPIRoutes,
};

export default routes;
Expand Down Expand Up @@ -307,31 +308,32 @@ const JAVASCRIPT = (pluginName: string): TemplateFile[] => [
`,
},
{
name: 'server/src/routes/content-api.js',
name: 'server/src/routes/content-api/index.js',
contents: outdent`
export default [
{
method: 'GET',
path: '/',
// name of the controller file & the method.
handler: 'controller.index',
config: {
policies: [],
},
},
];
export default () => ({
type: 'content-api',
routes: [],
});
`,
},
{
name: 'server/src/routes/admin/index.js',
contents: outdent`
export default () => ({
type: 'admin',
routes: [],
});
`,
},
{
name: 'server/src/routes/index.js',
contents: outdent`
import contentAPIRoutes from './content-api';
import adminAPIRoutes from './admin';

const routes = {
'content-api': {
type: 'content-api',
routes: contentAPIRoutes,
},
'content-api': contentAPIRoutes,
admin: adminAPIRoutes,
};

export default routes;
Expand Down