Create routers
Course: PayTM project - chapter 3
In the index.js file, route all the requests to /api/v1 to a apiRouter defined in backend/routes/index.js
Step 1
Section titled “Step 1”Create a new file backend/routes/index.js that exports a new express router.
( How to create a router - https://www.geeksforgeeks.org/express-js-express-router-function/ )
Solution
const express = require('express');
const router = express.Router();
module.exports = router;Step 2
Section titled “Step 2”Import the router in index.js and route all requests from /api/v1 to it
Solution
const express = require("express");const rootRouter = require("./routes/index");
const app = express();
app.use("/api/v1", rootRouter);