You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create the routes file using the boilerplate code below in the folder ./src/routes.
constconfig=require("../config/config");constversion=config.get("version");constcontroller=require("../controllers/CONTROLLER_NAME");module.exports=function(app){// This route creates a game and returns a joinable url and admin access token.app.route("/api/"+version+"/ROUTE_SLUG").get(controller.CONTROLLER_FUNCTION);};
Then Create the controller in the folder ./src/controllers using the boilerplate code.
// Require configconstconfig=require("../config/config");// Import JWTvarjwt=require('jsonwebtoken');// CreateGame function creates a yoinked game when triggered.constCONTROLLER_FUNCTION=(req,res)=>{returnres.send({message: "Hello World!"});};// export all functionsmodule.exports={CONTROLLER_FUNCTION,};
Add the route file in the directory: ./src/config/express.js add the route file using the code below.
require("../routes/ROUTE_FILE")(app);
Creating a new mongoose schema
Make the new model using the code below and save it inside ./src/models/ using convention name.model.js,