I am going to have multiple APIs in routes folder should I put them in in the same file API or separate them?
├── app.js
├── src/
│ ├── contants/
│ ├── helpers/
│ ├── models/
│ ├── routes/
| | |___index.js
|___api.js
│ └── libs/
│ ├── backbone/
│ ├── underscore/
│ └── ...
api.js file contains all the APIs
const jwt = require("jsonwebtoken")
const axios = require("axios")
require("express-async-errors")
const bodyParser = require("body-parser")
const fs = require("fs")
const LOLTrackingSystem = require("../methods/onlineGamesTracking/LOLTracking")
const getUserData = require("../methods/leagueOfLegends/getUserData")
const isAuthenticated = require("../helpers/authenticated")
const apiRoute = (api) => {
api.use(bodyParser.json())
api.use(bodyParser.urlencoded({
extended: false
}));
api.post("/api/auth", (req, res) => {
//API Functions
})
api.post("/api/gizmo/memberProfile", isAuthenticated, (req, res) => {
//API Functions
})
api.post("/api/gizmo/memberState/:userId/:host/:state", async (req, res) => {
//API Functions
})
}
module.exports = apiRoute
Is what I am doing is right?
If it's wrong what is the right way to do it?