Skip to content

Commit

Permalink
fix: incorrect route id (#124)
Browse files Browse the repository at this point in the history
close #123
  • Loading branch information
yesmeck authored Dec 11, 2024
1 parent 747fc68 commit c40ca54
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ function exportedQuery(ctx: Context) {
}

function routes(ctx: Context) {
const routes = ctx.routes.map(({ route, params, fileName }) =>
const routes = ctx.routes.map(({ id, route, params, fileName }) =>
`"${route}": {
id: '${route}',
id: '${id}',
params: ${params.length > 0 ? `{${params.map(param => `${param}: string | number`).join('; ')}}` : 'never'},
query: ExportedQuery<import('${ctx.relativeAppDirPath}/${fileName}').SearchParams>,
}`
Expand Down
54 changes: 27 additions & 27 deletions tests/__snapshots__/build.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,137 +10,137 @@ exports[`gen route types 1`] = `
export interface Routes {
"/": {
id: '/',
id: 'root',
params: never,
query: ExportedQuery<import('../app/root').SearchParams>,
},
"/:lang?/about": {
id: '/:lang?/about',
id: 'routes/($lang).about',
params: {lang?: string | number},
query: ExportedQuery<import('../app/routes/($lang).about').SearchParams>,
},
"/admin": {
id: '/admin',
id: 'routes/admin._index',
params: never,
query: ExportedQuery<import('../app/routes/admin._index').SearchParams>,
},
"/admin/episodes": {
id: '/admin/episodes',
id: 'routes/admin.episodes._index',
params: never,
query: ExportedQuery<import('../app/routes/admin.episodes._index').SearchParams>,
},
"/admin/episodes/:id": {
id: '/admin/episodes/:id',
id: 'routes/admin.episodes.$id._index',
params: {id: string | number},
query: ExportedQuery<import('../app/routes/admin.episodes.$id._index').SearchParams>,
},
"/admin/episodes/:id/comments": {
id: '/admin/episodes/:id/comments',
id: 'routes/admin.episodes.$id.comments',
params: {id: string | number},
query: ExportedQuery<import('../app/routes/admin.episodes.$id.comments').SearchParams>,
},
"/admin/episodes/new": {
id: '/admin/episodes/new',
id: 'routes/admin.episodes.new',
params: never,
query: ExportedQuery<import('../app/routes/admin.episodes.new').SearchParams>,
},
"/api/:id.json": {
id: '/api/:id.json',
id: 'routes/api.$id[.]json',
params: {id: string | number},
query: ExportedQuery<import('../app/routes/api.$id[.]json').SearchParams>,
},
"/auth": {
id: '/auth',
id: 'routes/auth._auth',
params: never,
query: ExportedQuery<import('../app/routes/auth._auth').SearchParams>,
},
"/auth/login": {
id: '/auth/login',
id: 'routes/auth._auth.login',
params: never,
query: ExportedQuery<import('../app/routes/auth._auth.login').SearchParams>,
},
"/blog/rss.xml": {
id: '/blog/rss.xml',
id: 'routes/blog.rss[.]xml',
params: never,
query: ExportedQuery<import('../app/routes/blog.rss[.]xml').SearchParams>,
},
"/chats/:season/:episode": {
id: '/chats/:season/:episode',
id: 'routes/chats_.$season.$episode',
params: {season: string | number; episode: string | number},
query: ExportedQuery<import('../app/routes/chats_.$season.$episode').SearchParams>,
},
"/chats/:season/:episode/:slug": {
id: '/chats/:season/:episode/:slug',
id: 'routes/chats_.$season.$episode.$slug',
params: {season: string | number; episode: string | number; slug: string | number},
query: ExportedQuery<import('../app/routes/chats_.$season.$episode.$slug').SearchParams>,
},
"/credits": {
id: '/credits',
id: 'routes/credits',
params: never,
query: ExportedQuery<import('../app/routes/credits').SearchParams>,
},
"/home": {
id: '/home',
id: 'routes/(static).home',
params: never,
query: ExportedQuery<import('../app/routes/(static).home').SearchParams>,
},
"/jokes": {
id: '/jokes',
id: 'routes/jokes._index',
params: never,
query: ExportedQuery<import('../app/routes/jokes._index').SearchParams>,
},
"/jokes/:jokeId": {
id: '/jokes/:jokeId',
id: 'routes/jokes.$jokeId',
params: {jokeId: string | number},
query: ExportedQuery<import('../app/routes/jokes.$jokeId').SearchParams>,
},
"/people/:personId": {
id: '/people/:personId',
id: 'routes/people.$personId',
params: {personId: string | number},
query: ExportedQuery<import('../app/routes/people.$personId').SearchParams>,
},
"/people/:personId/:planId/remove-plan": {
id: '/people/:personId/:planId/remove-plan',
id: 'routes/people.$personId.$planId.remove-plan',
params: {personId: string | number; planId: string | number},
query: ExportedQuery<import('../app/routes/people.$personId.$planId.remove-plan').SearchParams>,
},
"/posts": {
id: '/posts',
id: 'routes/posts._index',
params: never,
query: ExportedQuery<import('../app/routes/posts._index').SearchParams>,
},
"/posts/:id": {
id: '/posts/:id',
id: 'routes/posts.$id',
params: {id: string | number},
query: ExportedQuery<import('../app/routes/posts.$id').SearchParams>,
},
"/posts/*": {
id: '/posts/*',
id: 'routes/posts.$',
params: {"*": string | number},
query: ExportedQuery<import('../app/routes/posts.$').SearchParams>,
},
"/posts/delete": {
id: '/posts/delete',
id: 'routes/posts.delete',
params: never,
query: ExportedQuery<import('../app/routes/posts.delete').SearchParams>,
},
"/s/:query": {
id: '/s/:query',
id: 'routes/s.$query',
params: {query: string | number},
query: ExportedQuery<import('../app/routes/s.$query').SearchParams>,
},
"/sign-in/*": {
id: '/sign-in/*',
id: 'routes/sign-in.$',
params: {"*": string | number},
query: ExportedQuery<import('../app/routes/sign-in.$').SearchParams>,
},
"/somewhere/cool/*": {
id: '/somewhere/cool/*',
id: 'catchall',
params: {"*": string | number},
query: ExportedQuery<import('../app/catchall').SearchParams>,
},
"/static/home": {
id: '/static/home',
id: 'routes/(static).home',
params: never,
query: ExportedQuery<import('../app/routes/(static).home').SearchParams>,
}
Expand Down

0 comments on commit c40ca54

Please sign in to comment.