var fs = require('fs');

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

    var resultContext = false;

    NServer.NControllers.Settings = class Settings extends Controller{

      action(a_request) {
        let self = this;
        a_request.setHeader("Content-Type", "application/javascript");
        if (!resultContext)
          resultContext = "fcf.application.appendPackageRawObject('fcf', " + 
                          JSON.stringify({
                            aliases: fcf.application.getThemes().getAliases(),
                            filters: fcf.application.getConfiguration().filters
                          }) + 
                          ");";
        a_request.send(resultContext);
      }

    }

    return NServer.NControllers.Settings;
  }
});
