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

Middleware to add a root path to the app routes #107

Open
NikhilNanjappa opened this issue May 18, 2022 · 0 comments
Open

Middleware to add a root path to the app routes #107

NikhilNanjappa opened this issue May 18, 2022 · 0 comments

Comments

@NikhilNanjappa
Copy link

NikhilNanjappa commented May 18, 2022

Hi guys,

I just wanted to check if I can add a root path to all the express routes ?

In express, the similar can be achieved using the below code

app.use('/api/v1', allRoutes);

So basically, any route like /product/:id would become /api/v1/product/:id.

I tried doing something similar using middlewares but unfortunately it didnt work

  {
    id: 'root-path',
    url: '/api/v1',
    method: ["GET", "POST", "PUT", "PATCH"],
    variants: [
      {
        id: 'enabled',
        response: (req, res, next) => next(),
      },
    ],
  },
@NikhilNanjappa NikhilNanjappa changed the title Middleware to add a root path to the app Middleware to add a root path to the app routes May 18, 2022
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