mockserver icon indicating copy to clipboard operation
mockserver copied to clipboard

Middleware to add a root path to the app routes

Open NikhilNanjappa opened this issue 2 years ago • 0 comments

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 avatar May 18 '22 12:05 NikhilNanjappa