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

Problem to create routings #1121

Closed
kotsmile opened this issue Aug 27, 2023 · 5 comments
Closed

Problem to create routings #1121

kotsmile opened this issue Aug 27, 2023 · 5 comments
Labels
good first issue Good for newcomers question Further information is requested

Comments

@kotsmile
Copy link

I want to combine

GET /api/users
POST /api/users
GET /api/users/:id
PATCH /api/users/:id
DELETE /api/users/:id

With current architecture of routings it seems impossible

@RobinTail RobinTail added the question Further information is requested label Aug 27, 2023
@RobinTail
Copy link
Owner

@kotsmile ,

you need to read the following two articles in order to achieve the desired configuration:

  1. https://github.com/RobinTail/express-zod-api#multiple-schemas-for-one-route
  2. https://github.com/RobinTail/express-zod-api#route-path-params

This should help you to make it possible.
If not, please let me know in another issue.

@RobinTail
Copy link
Owner

const routing: Routing = {
  api: {
    users: {
      "": new DependsOnMethod({
        get: getUsersEndpoint,
        post: makeUsersEndpoint,
      }),
      ":id": new DependsOnMethod({
        get: getUserByIdEndpoint,
        patch: changeUserByIdEndpoint,
        delete: deleteUserByIdEndpoint,
      })
    }
  }
}

@kotsmile

@RobinTail RobinTail added the good first issue Good for newcomers label Aug 27, 2023
@kotsmile
Copy link
Author

kotsmile commented Aug 28, 2023

@RobinTail thank you for your answer, its not obvious from the documentation how to achieve such a configuration (i mean empty quotes), perhaps need to add such an example to the documentation

@kotsmile
Copy link
Author

And I'm also in the process of writing an autorouting generator depending on the file structure, if it's useful I may add MR later on

@RobinTail
Copy link
Owner

perhaps need to add such an example to the documentation

I tried my best.

image

I'm open to other suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants