Code Monkey home page Code Monkey logo

ester-backend's Introduction

Documentation

Adding a new route

  1. 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);
};
  1. Then Create the controller in the folder ./src/controllers using 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,
};
  1. 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

  1. Make the new model using the code below and save it inside ./src/models/ using convention name.model.js,
const mongoose = require("mongoose");

const SCHEMA_NAME = new mongoose.Schema({});

mongoose.model(`MODEL_NAME`, SCHEMA_NAME);
  1. Add the import inside ./src/config/db.js at the top of the page, using the code require("../models/name.model")

Adding new value to model

  1. Add the key and value to the model located inside ./src/models/,
  2. Go to ./src/controllers/database.controller.js and add the new value to be saved to the database inside saveReviewToDatabase,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.