diff --git a/js/server/modules/org/arangodb/foxx/manager.js b/js/server/modules/org/arangodb/foxx/manager.js index 7a3c4fb580..65f5d02b78 100644 --- a/js/server/modules/org/arangodb/foxx/manager.js +++ b/js/server/modules/org/arangodb/foxx/manager.js @@ -1221,6 +1221,13 @@ exports.initializeFoxx = function () { // ----------------------------------------------------------------------------- var appCache = {}; + var usedSystemMountPoints = [ + "/_admin/aardvark", // Admin interface. + "/_system/cerberus", // Password recovery. + "/_api/gharial", // General_Graph API. + "/_system/sessions", // Sessions. + "/_system/simple-auth" // Authentication. + ]; // ----------------------------------------------------------------------------- // --SECTION-- private functions @@ -1246,6 +1253,21 @@ exports.initializeFoxx = function () { return routes; }; + //////////////////////////////////////////////////////////////////////////////// + /// @brief Makes sure all system apps are mounted. + //////////////////////////////////////////////////////////////////////////////// + var checkMountedSystemApps = function() { + var i, mount; + for (i = 0; i < usedSystemMountPoints.length; ++i) { + mount = usedSystemMountPoints[i]; + if (!appCache[mount]) { + // System app not written to collection + _scanFoxx(mount, {}); + setup(mount); + } + } + }; + //////////////////////////////////////////////////////////////////////////////// /// @brief lookup app in cache /// Returns either the app or undefined if it is not cached. @@ -1696,15 +1718,29 @@ exports.initializeFoxx = function () { } }; + //////////////////////////////////////////////////////////////////////////////// + /// @brief Internal scanFoxx function. Check scanFoxx. + /// Does not check parameters and throws errors. + //////////////////////////////////////////////////////////////////////////////// + + var _scanFoxx = function(mount, options) { + delete appCache[mount]; + var app = createApp(mount, options); + utils.tmp_getStorage().save(app.toJSON()); + }; + //////////////////////////////////////////////////////////////////////////////// /// @brief Scans the sources of the given mountpoint and publishes the routes /// /// TODO: Long Documentation! //////////////////////////////////////////////////////////////////////////////// var scanFoxx = function(mount, options) { - delete appCache[mount]; - var app = createApp(mount, options); - utils.tmp_getStorage().save(app.toJSON()); + checkParameter( + "mount()", + [ [ "Mount path", "string" ] ], + [ mount ] ); + _scanFoxx(mount, options); + executeGlobalContextFunction("reloadRouting"); }; @@ -1736,7 +1772,7 @@ exports.initializeFoxx = function () { // try appstore throw "Not implemented yet"; } - scanFoxx(mount, options); + _scanFoxx(mount, options); if (runSetup) { setup(mount); } @@ -1825,7 +1861,8 @@ exports.initializeFoxx = function () { //////////////////////////////////////////////////////////////////////////////// var initializeFoxx = function() { - return refillCaches(false); + refillCaches(false); + checkMountedSystemApps(); }; var appRoutes = function() {