mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into devel
This commit is contained in:
commit
8cee3cedcb
|
@ -44,7 +44,7 @@ exports.createQuery = createQuery;
|
||||||
exports.toJSONSchema = toJSONSchema;
|
exports.toJSONSchema = toJSONSchema;
|
||||||
exports.requireApp = function (path) {
|
exports.requireApp = function (path) {
|
||||||
'use strict';
|
'use strict';
|
||||||
return manager.mountedApp(arangodb.normalizeURL('/' + path));
|
return manager.requireApp(arangodb.normalizeURL('/' + path));
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
@ -47,6 +47,25 @@
|
||||||
var errors = arangodb.errors;
|
var errors = arangodb.errors;
|
||||||
var throwFileNotFound = arangodb.throwFileNotFound;
|
var throwFileNotFound = arangodb.throwFileNotFound;
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// --SECTION-- private functions
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
var applyDefaultConfig = function(config) {
|
||||||
|
if (config === undefined) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
var res = {};
|
||||||
|
var attr;
|
||||||
|
for (attr in config) {
|
||||||
|
if (config.hasOwnProperty(attr) && config[attr].hasOwnProperty("default")) {
|
||||||
|
res[attr] = config[attr].default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- constructors and destructors
|
// --SECTION-- constructors and destructors
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -137,6 +156,11 @@
|
||||||
this._isDevelopment = config.isDevelopment || false;
|
this._isDevelopment = config.isDevelopment || false;
|
||||||
this._exports = {};
|
this._exports = {};
|
||||||
this._collectionPrefix = this._mount.substr(1).replace(/-/g, "_").replace(/\//g, "_") + "_";
|
this._collectionPrefix = this._mount.substr(1).replace(/-/g, "_").replace(/\//g, "_") + "_";
|
||||||
|
// Apply the default configuration and ignore all missing options
|
||||||
|
|
||||||
|
var cfg = config.options.configuration;
|
||||||
|
this._options.configuration = applyDefaultConfig(this._manifest.configuration);
|
||||||
|
this.configure(cfg);
|
||||||
this._context = new AppContext(this);
|
this._context = new AppContext(this);
|
||||||
|
|
||||||
if (! this._manifest.hasOwnProperty("defaultDocument")) {
|
if (! this._manifest.hasOwnProperty("defaultDocument")) {
|
||||||
|
|
|
@ -960,7 +960,7 @@
|
||||||
"configure(<mount>)",
|
"configure(<mount>)",
|
||||||
[ [ "Mount path", "string" ] ],
|
[ [ "Mount path", "string" ] ],
|
||||||
[ mount ] );
|
[ mount ] );
|
||||||
utils.validateMount(mount);
|
utils.validateMount(mount, true);
|
||||||
var app = lookupApp(mount);
|
var app = lookupApp(mount);
|
||||||
var invalid = app.configure(options);
|
var invalid = app.configure(options);
|
||||||
if (invalid.length > 0) {
|
if (invalid.length > 0) {
|
||||||
|
@ -981,11 +981,22 @@
|
||||||
"configuration(<mount>)",
|
"configuration(<mount>)",
|
||||||
[ [ "Mount path", "string" ] ],
|
[ [ "Mount path", "string" ] ],
|
||||||
[ mount ] );
|
[ mount ] );
|
||||||
utils.validateMount(mount);
|
utils.validateMount(mount, true);
|
||||||
var app = lookupApp(mount);
|
var app = lookupApp(mount);
|
||||||
return app.getConfiguration();
|
return app.getConfiguration();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var requireApp = function(mount) {
|
||||||
|
checkParameter(
|
||||||
|
"requireApp(<mount>)",
|
||||||
|
[ [ "Mount path", "string" ] ],
|
||||||
|
[ mount ] );
|
||||||
|
utils.validateMount(mount, true);
|
||||||
|
var app = lookupApp(mount);
|
||||||
|
require("console").log("Exports:", app._exports);
|
||||||
|
return app._exports;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- exports
|
// --SECTION-- exports
|
||||||
|
@ -1005,6 +1016,7 @@
|
||||||
exports.production = setProduction;
|
exports.production = setProduction;
|
||||||
exports.configure = configure;
|
exports.configure = configure;
|
||||||
exports.configuration = configuration;
|
exports.configuration = configuration;
|
||||||
|
exports.requireApp = requireApp;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Serverside only API
|
/// @brief Serverside only API
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
var arangodb = require("org/arangodb");
|
var arangodb = require("org/arangodb");
|
||||||
|
var ArangoError = arangodb.ArangoError;
|
||||||
|
var errors = arangodb.errors;
|
||||||
var preprocess = require("org/arangodb/foxx/preprocessor").preprocess;
|
var preprocess = require("org/arangodb/foxx/preprocessor").preprocess;
|
||||||
var _ = require("underscore");
|
var _ = require("underscore");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
@ -43,7 +45,6 @@
|
||||||
var frontendDevelopmentMode = require("internal").frontendDevelopmentMode;
|
var frontendDevelopmentMode = require("internal").frontendDevelopmentMode;
|
||||||
var console = require("console");
|
var console = require("console");
|
||||||
var actions = require("org/arangodb/actions");
|
var actions = require("org/arangodb/actions");
|
||||||
var utils = require("org/arangodb/foxx/manager-utils");
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- private functions
|
// --SECTION-- private functions
|
||||||
|
@ -379,12 +380,12 @@
|
||||||
/// @brief transform the internal route objects into proper routing callbacks
|
/// @brief transform the internal route objects into proper routing callbacks
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
var transformRoutes = function (rt, routes, controller, prefix) {
|
var transformRoutes = function (rt, routes, controller, prefix, isDevel) {
|
||||||
var j, route;
|
var j, route;
|
||||||
for (j = 0; j < rt.length; ++j) {
|
for (j = 0; j < rt.length; ++j) {
|
||||||
route = rt[j];
|
route = rt[j];
|
||||||
route.action = {
|
route.action = {
|
||||||
callback: transformControllerToRoute(route.action, route.url || "No Route")
|
callback: transformControllerToRoute(route.action, route.url || "No Route", isDevel)
|
||||||
};
|
};
|
||||||
if (route.hasOwnProperty("url")) {
|
if (route.hasOwnProperty("url")) {
|
||||||
route.url.match = arangodb.normalizeURL(prefix + "/" + route.url.match);
|
route.url.match = arangodb.normalizeURL(prefix + "/" + route.url.match);
|
||||||
|
@ -394,6 +395,26 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var routeRegEx = /^(\/:?[a-zA-Z0-9_\-%]+)+\/?$/;
|
||||||
|
|
||||||
|
var validateRoute = function(route) {
|
||||||
|
if (route[0] !== "/") {
|
||||||
|
throw new ArangoError({
|
||||||
|
errorNum: errors.ERROR_INVALID_MOUNTPOINT.code,
|
||||||
|
errorMessage: "Route has to start with /."
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!routeRegEx.test(route)) {
|
||||||
|
// Controller routes may be /. Foxxes are not allowed to
|
||||||
|
if (route.length !== 1) {
|
||||||
|
throw new ArangoError({
|
||||||
|
errorNum: errors.ERROR_INVALID_MOUNTPOINT.code,
|
||||||
|
errorMessage: "Route parts '" + route + "' may only contain a-z, A-Z, 0-9 or _. But may start with a :"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- public functions
|
// --SECTION-- public functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -472,7 +493,7 @@
|
||||||
try {
|
try {
|
||||||
for (i in controllers) {
|
for (i in controllers) {
|
||||||
if (controllers.hasOwnProperty(i)) {
|
if (controllers.hasOwnProperty(i)) {
|
||||||
utils.validateMount(i, true);
|
validateRoute(i);
|
||||||
file = controllers[i];
|
file = controllers[i];
|
||||||
|
|
||||||
// set up a context for the application start function
|
// set up a context for the application start function
|
||||||
|
|
|
@ -1454,7 +1454,7 @@ function updateGlobals() {
|
||||||
try {
|
try {
|
||||||
mapAppZip[tmp.app] = fmUtils.zipDirectory(path);
|
mapAppZip[tmp.app] = fmUtils.zipDirectory(path);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.errorLines("Tried to move app " + tmp.app + " but it was not found at app-path" + path +
|
logger.errorLines("Tried to move app " + tmp.app + " but it was not found at app-path " + path +
|
||||||
" : " +(e.stack || String(e)));
|
" : " +(e.stack || String(e)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1484,7 +1484,7 @@ function updateGlobals() {
|
||||||
try {
|
try {
|
||||||
fs.removeDirectoryRecursive(module.oldAppPath(), true);
|
fs.removeDirectoryRecursive(module.oldAppPath(), true);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
logger.log("Unable to remove old app path %s", module.oldAppPath());
|
logger.warn("Unable to remove old app path " + module.oldAppPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. For each mounted app, reinstall appId from zipFile to mount
|
// 4. For each mounted app, reinstall appId from zipFile to mount
|
||||||
|
|
Loading…
Reference in New Issue