Skip to content

add routes command #742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

add routes command #742

wants to merge 1 commit into from

Conversation

creeefs
Copy link

@creeefs creeefs commented Mar 28, 2021

Add svelte-kit routes command

While reading #738, I thought adding a svelte-kit routes command would be a helpful command to help mitigate the difficulty of knowing what routes are available as the file structure grows. The current version of the PR is very crude (i.e. just prints the route objects), but if the team finds this useful, we could prettify the output. Additionally, I can see this command helping users understand trickier route behavior (e.g. "fallthrough" routes).

Example

> svelte-kit routes

[
  {
    type: 'page',
    pattern: /^\/$/,
    params: [],
    parts: [ 'src/routes/index.svelte' ]
  },
  {
    type: 'endpoint',
    pattern: /^\/about\/?$/,
    file: 'src/routes/about.js',
    params: []
  },
  {
    type: 'page',
    pattern: /^\/about\/?$/,
    params: [],
    parts: [ 'src/routes/about.svelte' ]
  }
]

Inspiration for this comes from rails routes.

@vercel
Copy link

vercel bot commented Mar 28, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/sveltejs/kit/ECJEcBsPva5BxF9uLVNYwCKdMbBg
✅ Preview: Canceled

[Deployment for 20227a5 canceled]

@benmccann
Copy link
Member

One alternative idea, should we provide some built-in page to handle this in dev mode?

@Conduitry
Copy link
Member

A benefit of having it be a page is that we could make it be like a 'routes playground' thing, where you can see what things in what order would be attempted to use to display the page for a given URL.

@creeefs
Copy link
Author

creeefs commented Apr 5, 2021

Yea, I think a page could be really cool too. Swagger docs allow you to test your endpoints easily. I think there are good use cases for both a cli command as well as a web page.

@benmccann
Copy link
Member

Thanks for sharing this idea! Since we'd still need to work out exactly what we want this to look like, it's probably best to have the discussion in an issue. I'm going to close this as a result so that we can keep the PR queue clean

@benmccann benmccann closed this Apr 18, 2021
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.

None yet

3 participants