version control api nodejs best practices

Solutions on MaxInterview for version control api nodejs best practices by the best coders in the world

showing results for - "version control api nodejs best practices"
Luana
04 Sep 2020
1//version taken out from header
2
3    app.use(function(req, res, next)
4    {
5       req.version = req.headers['accept-version'];
6       console.log(req.version);
7       next();
8    });
9
10    //version path defined
11
12    app.use('/api', versionRoutes({  
13       "1.0.0": respondV1,
14       "2.0.0": respondV2
15    }));
16
17    function respondV1(req, res, next)
18     {   
19        app.use('/api',routeV1);
20        next();
21     }
22    function respondV2(req, res, next)
23    {
24       app.use('/api',routeV2);
25       next();
26    }*
27