- Create the routes file using the boilerplate code below in the folder
./src/routes.
const config = require("../config/config");
const version = config.get("version");
const controller = 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/controllersusing the boilerplate code.
// Require config
const config = require("../config/config");
// Import JWT
var jwt = require('jsonwebtoken');
// CreateGame function creates a yoinked game when triggered.
const CONTROLLER_FUNCTION = (req, res) => {
return res.send({ message: "Hello World!" });
};
// export all functions
module.exports = {
CONTROLLER_FUNCTION,
};- Add the route file in the directory:
./src/config/express.jsadd the route file using the code below.
require("../routes/ROUTE_FILE")(app);- Make the new model using the code below and save it inside
./src/models/using conventionname.model.js,
const mongoose = require("mongoose");
const SCHEMA_NAME = new mongoose.Schema({});
mongoose.model(`MODEL_NAME`, SCHEMA_NAME);- Add the import inside
./src/config/db.jsat the top of the page, using the coderequire("../models/name.model")
- Add the key and value to the model located inside
./src/models/, - Go to
./src/controllers/database.controller.jsand add the new value to be saved to the database insidesaveReviewToDatabase,