Skip to content
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

Cannot pass wildcard params (+Workaround) #96

Open
jakob-kruse opened this issue May 24, 2024 · 0 comments
Open

Cannot pass wildcard params (+Workaround) #96

jakob-kruse opened this issue May 24, 2024 · 0 comments

Comments

@jakob-kruse
Copy link

Problem

It currently is not possible to provide wildcard parameters with eden treaty.

With dynamic params the client type is this:

api: {
  files: ((params: {
    path: string | number;
  }) => {
  // ...

With a wildcard it becomes this:

api: {
  files: {
    "*": {
    // ...

It should also become a function in my opinion. Please let me know if i missed something or you need a reproduction repo!

Workaround / Repro:

export const api = new Elysia({ prefix: '/api' })
  // Never called just used for types
  .get('/files/:path', ({ params }) => {
    return doStuff(params.path);
  })
  .get('/files/*', ({ params }) => {
    return doStuff(params['*']);
  });

export type Api = typeof api;

async function clientCode() {
  await apiClient.api.files({ path: '/test/path' }).get();
}
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

No branches or pull requests

1 participant