var fs = require('fs');

fcf.module({
  name: "fcf:NServer/NControllers/Settings.js",
  dependencies: ["fcf:NServer/NControllers/Controller.js"],
  module: function(Controller) {
    fcf.prepareObject(fcf, "NServer.NControllers");

    var resultContext = false;

    fcf.NServer.NControllers.Settings = class Settings extends Controller{

      getRequestInfo(){
        return {
          userRequest: false,
          redirect:    false,
        };
      }

      action(a_request) {
        let self = this;
        a_request.setHeader("Content-Type", "application/javascript");
        if (!resultContext)
          resultContext = "fcf.application.setEnvironment(" +
                          JSON.stringify({
                            aliases:     fcf.application.getTheme().getAliases(),
                            filters:     fcf.application.getConfiguration().filters,
                            decor:       fcf.application.getTheme().getDecor(),
                            defaultArgs: fcf.application.getConfiguration().defaultArgs,
                            usageViews:  fcf.application.getTheme().getInfo().usageViews ? fcf.application.getTheme().getInfo().usageViews : {},
                          }) +
                          ");";
        a_request.send(resultContext);
      }

    }

    return fcf.NServer.NControllers.Settings;
  }
});
