h3 icon indicating copy to clipboard operation
h3 copied to clipboard

infer route params

Open huseeiin opened this issue 8 months ago • 8 comments

Describe the feature

import { H3 } from "h3-nightly" // 2.0.0-20250428-102154-f1115f3;

const app = new H3();

app.get("/:user/id", (e) => {
  console.log(e.context.params); // Record<string, string> | undefined;
});

could this be helpful? https://github.com/lukeed/regexparam/blob/main/index.d.ts#L11

Additional information

  • [ ] Would you be willing to help implement this feature?

huseeiin avatar May 11 '25 11:05 huseeiin

/cc @danielroe Do you think we could have a mini util from fetch-dts to unblock this? (bun also has similar feature in their types)

pi0 avatar May 12 '25 21:05 pi0

/cc @danielroe Do you think we could have a mini util from fetch-dts to unblock this? (bun also has similar feature in their types)

but we should make sure it 100% matches rou3 conventions

huseeiin avatar May 13 '25 09:05 huseeiin

/cc @danielroe Do you think we could have a mini util from fetch-dts to unblock this? (bun also has similar feature in their types)

In addition to Bun, there is also SvelteKit. If H3 supports this feature, Nitro will benefit greatly.

medz avatar Jun 04 '25 18:06 medz

i think the util that will be created to infer params from a string should be exported by rou3 too :)

huseeiin avatar Aug 03 '25 13:08 huseeiin

Feel feee to open Issue and work on PR for rou3 @huseeiin 😊

pi0 avatar Aug 03 '25 13:08 pi0

Feel feee to open Issue and work on PR for rou3 @huseeiin 😊

unfortunately i'm not a typescript type magician xd

huseeiin avatar Aug 03 '25 13:08 huseeiin

Pending for https://github.com/h3js/rou3/issues/167

pi0 avatar Aug 03 '25 19:08 pi0

https://github.com/h3js/rou3/pull/168 just landed (thanks @luxass ❤️)

now we can move ahead with this.

pi0 avatar Oct 01 '25 09:10 pi0