const express = require("express");
const path = require("path");

// Classes
const Wwws = require("../models/Wwws.js");
// Middlewares
const checkHeaders = require("../middlewares/checkHeaders");
const isAuthenticated = require("../middlewares/isAuthenticated");

const router = express.Router();

/**
 * To manage an nginx conf
 *
 */

router.get("/tribes/:tribeId", checkHeaders, isAuthenticated, (req, res) => {
  /**
   * @api {get} /www/tribes/:tribeId
   * @apiName Get list of application Name
   * @apiGroup Www
   *
   * @apiUse apxHeader
   *
   * @apiParam {String} tribeId Mandatory that have to exist in current town and
   *
   * @apiError (404) {string} status the folder does not exist
   * @apiError (404) {string} ref objectmodel to get in the right language
   * @apiError (404) {string} msg key to get template from objectmodel
   * @apiError (404) {object} data use to www's model: 'Www' } );render lg/objectmodel_lg.json
   *
   * @apiSuccess (200) {object} data contains liste of www conf of a tribe
   *
   */

  res.send(Www.configlist(req.params.tribeId));
});
router.post("/:webappname", checkHeaders, isAuthenticated, (req, res) => {
  /**
   * Create a space web /tribes/www/webappname
   *
   *
   * */
  res.send(Wwws.create(req.params.tribeId));
});
module.exports = router;
