1
0
Fork 0

Merge branch 'devel' of https://github.com/arangodb/arangodb into devel

This commit is contained in:
Jan Steemann 2015-06-03 14:57:27 +02:00
commit 7426e9908d
12 changed files with 1844 additions and 1832 deletions

View File

@ -5,6 +5,9 @@ The ArangoDB server can listen for incoming requests on multiple *endpoints*.
The endpoints are normally specified either in ArangoDB's configuration file or on
the command-line, using the ["--server.endpoint"](../ConfigureArango/Arangod.md) option.
The default endpoint for ArangoDB is *tcp://127.0.0.1:8529* or *tcp://localhost:8529*.
ArangoDB can also do a so called *broadcast bind* using *tcp://0.0.0.0:8529*. This way
it will be reachable on all interfaces of the host. This may be useful
on development systems that frequently change their network setup like laptops.
The number of endpoints can also be changed at runtime using the API described
below. Each endpoint can optionally be restricted to a specific list of databases
@ -14,6 +17,23 @@ This may be useful in multi-tenant setups.
A multi-endpoint setup may also be useful to turn on encrypted communication for
just specific databases.
Endpoints equal TCP ports to be bound. On one specific ethernet interface each port
can only be bound **exactly once**. You can look up your available interfaces using
the *ifconfig* command on Linux / MacOSX - the Windows equivalent is *ipconfig*
([See Wikipedia for more details](http://en.wikipedia.org/wiki/Ifconfig)).
The general names of the interfaces differ on OS's and hardwares they run on.
However, typically every host has a so called
[loopback interface](http://en.wikipedia.org/wiki/Loop_device), which is a
virtual interface. By convention it always has the address *127.0.0.1* or *::1* (ipv6),
and can only be reached from exactly the very same host.
Ethernet interfaces usually have names like *eth0*, *wlan0*, *eth1:17*, *le0* or
a plain text name in Windows.
To find out which services already use ports (so ArangoDB can't bind them anymore),
you can use the [netstat command](http://en.wikipedia.org/wiki/Netstat)
(it behaves a little different on each platform, run it with *-lnpt* on Linux, *-p tcp*
on MacOSX or with *-an* on windows for valuable information).
The JavaScript interface for endpoints provides operations to add new endpoints at
runtime, and optionally restrict them for use with specific databases. The interface
also can be used to update existing endpoints or remove them at runtime.

View File

@ -12,5 +12,8 @@
"top": 35,
"bottom": 35
}
},
"styles": {
"website": "styles/website.css"
}
}

View File

@ -0,0 +1 @@
div.example_show_button { border: medium solid lightgray; text-align: center; position: relative; top: -10px; } .book .book-body .navigation.navigation-next { right: 10px !important; } .book .book-summary ul.summary li.active>a,.book .book-summary ul.summary li a:hover { color: #000 !important; background: #80A54D !important; text-decoration: none; } .book .book-body .page-wrapper .page-inner section.normal .deprecated{ background-color: rgba(240,240,0,0.4); } .gsib_a { padding: 0px !important; } .gsc-control-cse { border: 0px !important; background-color: transparent !important; } .gsc-input { margin: 0px !important; }

View File

@ -1993,16 +1993,10 @@ int TRI_StartServer (TRI_server_t* server,
if (server->_appPath != nullptr &&
strlen(server->_appPath) > 0 &&
! TRI_IsDirectory(server->_appPath)) {
if (! performUpgrade) {
LOG_ERROR("specified --javascript.app-path directory '%s' does not exist. "
"Please start again with --upgrade option to create it.",
server->_appPath);
return TRI_ERROR_BAD_PARAMETER;
}
long systemError;
std::string errorMessage;
res = TRI_CreateDirectory(server->_appPath, systemError, errorMessage);
int res = TRI_CreateRecursiveDirectory(server->_appPath, systemError, errorMessage);
if (res != TRI_ERROR_NO_ERROR) {
LOG_ERROR("unable to create --javascript.app-path directory '%s': %s",
@ -2010,6 +2004,10 @@ int TRI_StartServer (TRI_server_t* server,
errorMessage.c_str());
return res;
}
else {
LOG_INFO("created --javascript.app-path directory '%s'.",
server->_appPath);
}
}
// create subdirectories if not yet present

View File

@ -28,6 +28,7 @@
////////////////////////////////////////////////////////////////////////////////
#include "LogfileManager.h"
#include "Basics/files.h"
#include "Basics/hashes.h"
#include "Basics/json.h"
#include "Basics/logging.h"
@ -266,7 +267,18 @@ bool LogfileManager::prepare () {
_directory = (*_databasePath);
if (! basics::FileUtils::isDirectory(_directory)) {
LOG_FATAL_AND_EXIT("database directory '%s' does not exist.", _directory.c_str());
std::string systemErrorStr;
long errorNo;
int res = TRI_CreateRecursiveDirectory(_directory.c_str(), errorNo, systemErrorStr);
if (res != TRI_ERROR_NO_ERROR) {
LOG_FATAL_AND_EXIT("unable to create database directory: %s",
systemErrorStr.c_str());
}
else {
LOG_INFO("created database directory '%s'.",
_directory.c_str());
}
}
// append "/journals"

View File

@ -1,4 +1,5 @@
/*jshint unused: false */
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// @brief ArangoDB Application Launcher
@ -29,26 +30,24 @@
/// @author Copyright 2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
(function() {
'use strict';
// -----------------------------------------------------------------------------
// --SECTION-- imports
// -----------------------------------------------------------------------------
var arangodb = require("org/arangodb");
var arangosh = require("org/arangodb/arangosh");
var errors = arangodb.errors;
var ArangoError = arangodb.ArangoError;
var checkParameter = arangodb.checkParameter;
var arango = require("internal").arango;
var fs = require("fs");
var arangodb = require("org/arangodb");
var arangosh = require("org/arangodb/arangosh");
var errors = arangodb.errors;
var ArangoError = arangodb.ArangoError;
var checkParameter = arangodb.checkParameter;
var arango = require("internal").arango;
var fs = require("fs");
var throwFileNotFound = arangodb.throwFileNotFound;
var throwBadParameter = arangodb.throwBadParameter;
var throwFileNotFound = arangodb.throwFileNotFound;
var throwBadParameter = arangodb.throwBadParameter;
var utils = require("org/arangodb/foxx/manager-utils");
var store = require("org/arangodb/foxx/store");
var utils = require("org/arangodb/foxx/manager-utils");
var store = require("org/arangodb/foxx/store");
// -----------------------------------------------------------------------------
// --SECTION-- private functions
// -----------------------------------------------------------------------------
@ -57,7 +56,7 @@
/// @brief extracts command-line options
////////////////////////////////////////////////////////////////////////////////
var extractCommandLineOptions = function(args) {
var extractCommandLineOptions = function(args) {
var options = {};
var nargs = [];
@ -88,13 +87,13 @@
}
return { 'options': options, 'args': nargs };
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief extract options from CLI options
////////////////////////////////////////////////////////////////////////////////
var extractOptions = function (args) {
var extractOptions = function (args) {
var opts = extractCommandLineOptions(args);
if (3 < opts.args.length) {
var options = JSON.parse(opts.args[3]);
@ -116,13 +115,13 @@
}
return { configuration: opts.options };
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief prints out usage message for the command-line tool
////////////////////////////////////////////////////////////////////////////////
var cmdUsage = function () {
var cmdUsage = function () {
var printf = arangodb.printf;
var fm = "foxx-manager";
@ -133,7 +132,7 @@
printf("Further help:\n");
printf(" %s help for the list of foxx-manager commands\n", fm);
printf(" %s --help for the list of options\n", fm);
};
};
// -----------------------------------------------------------------------------
// --SECTION-- public functions
@ -144,7 +143,7 @@
/// @brief outputs the help
////////////////////////////////////////////////////////////////////////////////
var help = function () {
var help = function () {
/*jshint maxlen: 200 */
var commands = {
@ -199,7 +198,7 @@
// additional newline
arangodb.print();
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief runs a script on a Foxx application
@ -211,7 +210,7 @@
/// Output:
/// -
////////////////////////////////////////////////////////////////////////////////
var runScript = function(mount, name, options) {
var runScript = function(mount, name, options) {
checkParameter(
"run(<mount>, <name>, [<options>])",
[ [ "Mount path", "string" ], [ "Script name", "string" ] ],
@ -225,13 +224,13 @@
res = arango.POST("/_admin/foxx/script", JSON.stringify(req));
arangosh.checkRequestResult(res);
return res;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Zips and copies a local app to the server.
////////////////////////////////////////////////////////////////////////////////
var moveAppToServer = function(appInfo) {
var moveAppToServer = function(appInfo) {
if (! fs.exists(appInfo)) {
throwFileNotFound("Cannot find file: " + appInfo + ".");
}
@ -264,7 +263,7 @@
});
}
return response.filename;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Installs a new foxx application on the given mount point.
@ -272,7 +271,7 @@
/// TODO: Long Documentation!
////////////////////////////////////////////////////////////////////////////////
var install = function(appInfo, mount, options) {
var install = function(appInfo, mount, options) {
checkParameter(
"install(<appInfo>, <mount>, [<options>])",
[ [ "Install information", "string" ],
@ -297,7 +296,7 @@
version: res.version,
mount: res.mount
};
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Uninstalls the foxx application on the given mount point.
@ -305,7 +304,7 @@
/// TODO: Long Documentation!
////////////////////////////////////////////////////////////////////////////////
var uninstall = function(mount, options) {
var uninstall = function(mount, options) {
checkParameter(
"uninstall(<mount>, [<options>])",
[ [ "Mount path", "string" ] ],
@ -323,7 +322,7 @@
version: res.version,
mount: res.mount
};
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Replaces a foxx application on the given mount point by an other one.
@ -331,7 +330,7 @@
/// TODO: Long Documentation!
////////////////////////////////////////////////////////////////////////////////
var replace = function(appInfo, mount, options) {
var replace = function(appInfo, mount, options) {
checkParameter(
"replace(<appInfo>, <mount>, [<options>])",
[ [ "Install information", "string" ],
@ -356,7 +355,7 @@
version: res.version,
mount: res.mount
};
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Upgrade a foxx application on the given mount point by a new one.
@ -364,7 +363,7 @@
/// TODO: Long Documentation!
////////////////////////////////////////////////////////////////////////////////
var upgrade = function(appInfo, mount, options) {
var upgrade = function(appInfo, mount, options) {
checkParameter(
"upgrade(<appInfo>, <mount>, [<options>])",
[ [ "Install information", "string" ],
@ -388,13 +387,13 @@
version: res.version,
mount: res.mount
};
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Activate the development mode for the application on the given mount point.
////////////////////////////////////////////////////////////////////////////////
var development = function(mount) {
var development = function(mount) {
checkParameter(
"development(<mount>)",
[ [ "Mount path", "string" ] ],
@ -412,13 +411,13 @@
version: res.version,
mount: res.mount
};
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Activate the production mode for the application on the given mount point.
////////////////////////////////////////////////////////////////////////////////
var production = function(mount) {
var production = function(mount) {
checkParameter(
"production(<mount>)",
[ [ "Mount path", "string" ] ],
@ -436,13 +435,13 @@
version: res.version,
mount: res.mount
};
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Configure the app at the mountpoint
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief Configure the app at the mountpoint
////////////////////////////////////////////////////////////////////////////////
var configure = function(mount, options) {
var configure = function(mount, options) {
checkParameter(
"configure(<mount>)",
[ [ "Mount path", "string" ] ],
@ -459,13 +458,13 @@
version: res.version,
mount: res.mount
};
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Get the configuration for the app at the given mountpoint
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief Get the configuration for the app at the given mountpoint
////////////////////////////////////////////////////////////////////////////////
var configuration = function(mount) {
var configuration = function(mount) {
checkParameter(
"configuration(<mount>)",
[ [ "Mount path", "string" ] ],
@ -477,13 +476,13 @@
var res = arango.POST("/_admin/foxx/configuration", JSON.stringify(req));
arangosh.checkRequestResult(res);
return res;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Configure the dependencies of the app at the mountpoint
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief Configure the dependencies of the app at the mountpoint
////////////////////////////////////////////////////////////////////////////////
var setDependencies = function(mount, options) {
var setDependencies = function(mount, options) {
checkParameter(
"setDependencies(<mount>)",
[ [ "Mount path", "string" ] ],
@ -500,13 +499,13 @@
version: res.version,
mount: res.mount
};
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Get the dependencies of the app at the given mountpoint
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief Get the dependencies of the app at the given mountpoint
////////////////////////////////////////////////////////////////////////////////
var dependencies = function(mount) {
var dependencies = function(mount) {
checkParameter(
"dependencies(<mount>)",
[ [ "Mount path", "string" ] ],
@ -518,13 +517,13 @@
var res = arango.POST("/_admin/foxx/dependencies", JSON.stringify(req));
arangosh.checkRequestResult(res);
return res;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief run a Foxx application's tests
////////////////////////////////////////////////////////////////////////////////
var tests = function (mount, options) {
var tests = function (mount, options) {
checkParameter(
"tests(<mount>, [<options>])",
[ [ "Mount path", "string" ] ],
@ -538,13 +537,13 @@
var res = arango.POST("/_admin/foxx/tests", JSON.stringify(req));
arangosh.checkRequestResult(res);
return res;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief command line dispatcher
////////////////////////////////////////////////////////////////////////////////
var run = function (args) {
var run = function (args) {
if (args === undefined || args.length === 0) {
arangodb.print("Expecting a command, please try:\n");
cmdUsage();
@ -697,56 +696,55 @@
return 1;
}
};
};
// -----------------------------------------------------------------------------
// --SECTION-- exports
// -----------------------------------------------------------------------------
exports.install = install;
exports.setup = function (mount, opts) {return runScript(mount, "setup", opts);};
exports.teardown = function (mount, opts) {return runScript(mount, "teardown", opts);};
exports.run = runScript;
exports.tests = tests;
exports.uninstall = uninstall;
exports.replace = replace;
exports.upgrade = upgrade;
exports.development = development;
exports.production = production;
exports.configure = configure;
exports.configuration = configuration;
exports.setDependencies = setDependencies;
exports.dependencies = dependencies;
exports.install = install;
exports.setup = function (mount, opts) {return runScript(mount, "setup", opts);};
exports.teardown = function (mount, opts) {return runScript(mount, "teardown", opts);};
exports.run = runScript;
exports.tests = tests;
exports.uninstall = uninstall;
exports.replace = replace;
exports.upgrade = upgrade;
exports.development = development;
exports.production = production;
exports.configure = configure;
exports.configuration = configuration;
exports.setDependencies = setDependencies;
exports.dependencies = dependencies;
////////////////////////////////////////////////////////////////////////////////
/// @brief Clientside only API
////////////////////////////////////////////////////////////////////////////////
exports.run = run;
exports.help = help;
exports.run = run;
exports.help = help;
////////////////////////////////////////////////////////////////////////////////
/// @brief Exports from foxx utils module.
////////////////////////////////////////////////////////////////////////////////
exports.mountedApp = utils.mountedApp;
exports.list = utils.list;
exports.listJson = utils.listJson;
exports.listDevelopment = utils.listDevelopment;
exports.listDevelopmentJson = utils.listDevelopmentJson;
exports.mountedApp = utils.mountedApp;
exports.list = utils.list;
exports.listJson = utils.listJson;
exports.listDevelopment = utils.listDevelopment;
exports.listDevelopmentJson = utils.listDevelopmentJson;
////////////////////////////////////////////////////////////////////////////////
/// @brief Exports from foxx store module.
////////////////////////////////////////////////////////////////////////////////
exports.available = store.available;
exports.availableJson = store.availableJson;
exports.search = store.search;
exports.searchJson = store.searchJson;
exports.update = store.update;
exports.info = store.info;
exports.available = store.available;
exports.availableJson = store.availableJson;
exports.search = store.search;
exports.searchJson = store.searchJson;
exports.update = store.update;
exports.info = store.info;
}());
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
/*jslint continue:true */
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// @brief Foxx application store
@ -27,26 +27,23 @@
/// @author Copyright 2015, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
(function() {
'use strict';
// -----------------------------------------------------------------------------
// --SECTION-- global variables
// -----------------------------------------------------------------------------
var checkedFishBowl = false;
var checkedFishBowl = false;
// -----------------------------------------------------------------------------
// --SECTION-- imports
// -----------------------------------------------------------------------------
var arangodb = require("org/arangodb");
var db = arangodb.db;
var download = require("internal").download;
var fs = require("fs");
var throwDownloadError = arangodb.throwDownloadError;
var utils = require("org/arangodb/foxx/manager-utils");
var arangodb = require("org/arangodb");
var db = arangodb.db;
var download = require("internal").download;
var fs = require("fs");
var throwDownloadError = arangodb.throwDownloadError;
var utils = require("org/arangodb/foxx/manager-utils");
// -----------------------------------------------------------------------------
// --SECTION-- private functions
@ -56,9 +53,9 @@
/// @brief returns the fishbowl repository
////////////////////////////////////////////////////////////////////////////////
function getFishbowlUrl () {
function getFishbowlUrl () {
return "arangodb/foxx-apps";
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the fishbowl collection
@ -68,7 +65,7 @@
/// used in context of the database.
////////////////////////////////////////////////////////////////////////////////
var getFishbowlStorage = function() {
var getFishbowlStorage = function() {
var c = db._collection('_fishbowl');
if (c === null) {
@ -83,13 +80,13 @@
}
return c;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief comparator for applications
////////////////////////////////////////////////////////////////////////////////
var compareApps = function(l, r) {
var compareApps = function(l, r) {
var left = l.name.toLowerCase();
var right = r.name.toLowerCase();
@ -102,13 +99,13 @@
}
return 0;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief comparator for versions
////////////////////////////////////////////////////////////////////////////////
var compareVersions = function (a, b) {
var compareVersions = function (a, b) {
var i;
if (a === b) {
@ -152,14 +149,14 @@
// Otherwise they are the same.
return 0;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief updates the fishbowl from a zip archive
////////////////////////////////////////////////////////////////////////////////
var updateFishbowlFromZip = function(filename) {
var updateFishbowlFromZip = function(filename) {
var i;
var tempPath = fs.getTempPath();
var toSave = [ ];
@ -251,7 +248,7 @@
throw err;
}
};
};
// -----------------------------------------------------------------------------
// --SECTION-- public functions
@ -261,7 +258,7 @@
/// @brief returns the search result for FOXX applications
////////////////////////////////////////////////////////////////////////////////
var searchJson = function (name) {
var searchJson = function (name) {
var fishbowl = getFishbowlStorage();
@ -303,14 +300,14 @@
}
return docs;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief searchs for an available FOXX applications
////////////////////////////////////////////////////////////////////////////////
var search = function (name) {
var search = function (name) {
var docs = searchJson(name);
arangodb.printTable(
@ -327,21 +324,21 @@
}
}
);
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief extracts the highest version number from the document
////////////////////////////////////////////////////////////////////////////////
function extractMaxVersion (versionDoc) {
var maxVersion = "-";
var versions = Object.keys(versionDoc);
versions.sort(compareVersions);
if (versions.length > 0) {
var maxVersion = "-";
var versions = Object.keys(versionDoc);
versions.sort(compareVersions);
if (versions.length > 0) {
versions.reverse();
maxVersion = versions[0];
}
return maxVersion;
}
return maxVersion;
}
////////////////////////////////////////////////////////////////////////////////
@ -349,12 +346,12 @@ function extractMaxVersion (versionDoc) {
////////////////////////////////////////////////////////////////////////////////
function availableJson() {
var fishbowl = getFishbowlStorage();
var cursor = fishbowl.all();
var result = [];
var doc, maxVersion, res;
var fishbowl = getFishbowlStorage();
var cursor = fishbowl.all();
var result = [];
var doc, maxVersion, res;
while (cursor.hasNext()) {
while (cursor.hasNext()) {
doc = cursor.next();
maxVersion = extractMaxVersion(doc.versions);
@ -366,9 +363,9 @@ function availableJson() {
};
result.push(res);
}
}
return result;
return result;
}
@ -379,7 +376,7 @@ function availableJson() {
////////////////////////////////////////////////////////////////////////////////
var update = function() {
var update = function() {
var url = utils.buildGithubUrl(getFishbowlUrl());
var filename = fs.getTempFile("downloads", false);
var path = fs.getTempFile("zip", false);
@ -412,13 +409,13 @@ function availableJson() {
throw err;
}
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief prints all available FOXX applications
////////////////////////////////////////////////////////////////////////////////
var available = function () {
var available = function () {
var list = availableJson();
arangodb.printTable(
@ -436,39 +433,39 @@ function availableJson() {
}
}
);
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief gets json-info for an available FOXX application
////////////////////////////////////////////////////////////////////////////////
var infoJson = function (name) {
utils.validateAppName(name);
utils.validateAppName(name);
var fishbowl = getFishbowlStorage();
var fishbowl = getFishbowlStorage();
if (fishbowl.count() === 0) {
if (fishbowl.count() === 0) {
arangodb.print("Repository is empty, please use 'update'");
return;
}
}
var desc;
var desc;
try {
try {
desc = fishbowl.document(name);
return desc;
}
catch (err) {
}
catch (err) {
arangodb.print("No application '" + name + "' available, please try 'search'");
return;
}
}
};
////////////////////////////////////////////////////////////////////////////////
/// @brief create a download URL for the given app information
////////////////////////////////////////////////////////////////////////////////
var buildUrl = function(appInfo) {
var buildUrl = function(appInfo) {
// TODO Validate
var infoSplit = appInfo.split(":");
var name = infoSplit[0];
@ -488,13 +485,13 @@ var infoJson = function (name) {
versionInfo = versions[version];
}
return utils.buildGithubUrl(versionInfo.location, versionInfo.tag);
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief prints info for an available FOXX application
////////////////////////////////////////////////////////////////////////////////
var info = function (name) {
var info = function (name) {
var desc = infoJson(name);
arangodb.printf("Name: %s\n", desc.name);
@ -535,25 +532,23 @@ var infoJson = function (name) {
});
arangodb.printf("\n");
};
};
// -----------------------------------------------------------------------------
// --SECTION-- export public API
// -----------------------------------------------------------------------------
exports.available = available;
exports.availableJson = availableJson;
exports.buildUrl = buildUrl;
exports.getFishbowlStorage = getFishbowlStorage;
exports.info = info;
exports.search = search;
exports.searchJson = searchJson;
exports.update = update;
exports.available = available;
exports.availableJson = availableJson;
exports.buildUrl = buildUrl;
exports.getFishbowlStorage = getFishbowlStorage;
exports.info = info;
exports.search = search;
exports.searchJson = searchJson;
exports.update = update;
// Temporary export to avoid breaking the client
exports.compareVersions = compareVersions;
}());
// Temporary export to avoid breaking the client
exports.compareVersions = compareVersions;
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE

View File

@ -1,4 +1,4 @@
/*jshint strict: false */
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// @brief Graph Data for Example
@ -26,11 +26,10 @@
/// @author Michael Hackstein
/// @author Copyright 2011-2014, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
(function() {
var Graph = require("org/arangodb/general-graph");
var Graph = require("org/arangodb/general-graph");
var createTraversalExample = function() {
var createTraversalExample = function() {
var g = Graph._create("knows_graph",
[Graph._relation("knows", "persons", "persons")]
);
@ -45,9 +44,9 @@
g.knows.save(e, a, {});
g.knows.save(e, b, {});
return g;
};
};
var createSocialGraph = function() {
var createSocialGraph = function() {
var edgeDefinition = [];
edgeDefinition.push(Graph._relation("relation", ["female", "male"], ["female", "male"]));
var g = Graph._create("social", edgeDefinition);
@ -60,9 +59,9 @@
g.relation.save(c._id, d._id, {type: "married", _key: "charlyAndDiana"});
g.relation.save(b._id, d._id, {type: "friend", _key: "bobAndDiana"});
return g;
};
};
var createRoutePlannerGraph = function() {
var createRoutePlannerGraph = function() {
var edgeDefinition = [];
edgeDefinition.push(Graph._relation(
"germanHighway", ["germanCity"], ["germanCity"])
@ -90,16 +89,16 @@
g.internationalHighway.save(cologne._id, lyon._id, {distance: 700});
g.internationalHighway.save(cologne._id, paris._id, {distance: 550});
return g;
};
};
var dropGraph = function(name) {
var dropGraph = function(name) {
if (Graph._exists(name)) {
return Graph._drop(name, true);
}
};
};
var loadGraph = function(name) {
var loadGraph = function(name) {
dropGraph(name);
switch (name) {
case "knows_graph":
@ -110,8 +109,7 @@
return createSocialGraph();
}
};
};
exports.loadGraph = loadGraph;
exports.dropGraph = dropGraph;
}());
exports.loadGraph = loadGraph;
exports.dropGraph = dropGraph;

View File

@ -1,4 +1,4 @@
/*jshint strict: false */
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// @brief Foxx application module
@ -28,30 +28,27 @@
/// @author Copyright 2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
(function() {
'use strict';
// -----------------------------------------------------------------------------
// --SECTION-- imports
// -----------------------------------------------------------------------------
var fs = require("fs");
var internal = require("internal");
var db = internal.db;
var _= require("underscore");
var utils = require("org/arangodb/foxx/manager-utils");
var console = require("console");
var arangodb = require("org/arangodb");
var ArangoError = arangodb.ArangoError;
var errors = arangodb.errors;
var throwFileNotFound = arangodb.throwFileNotFound;
var fs = require("fs");
var internal = require("internal");
var db = internal.db;
var _= require("underscore");
var utils = require("org/arangodb/foxx/manager-utils");
var console = require("console");
var arangodb = require("org/arangodb");
var ArangoError = arangodb.ArangoError;
var errors = arangodb.errors;
var throwFileNotFound = arangodb.throwFileNotFound;
// -----------------------------------------------------------------------------
// --SECTION-- private functions
// -----------------------------------------------------------------------------
function applyDefaultConfig(config) {
function applyDefaultConfig(config) {
var res = {};
if (config !== undefined) {
Object.keys(config).forEach(function (attr) {
@ -61,7 +58,7 @@
});
}
return res;
}
}
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
@ -71,7 +68,7 @@
// --SECTION-- AppContext
// -----------------------------------------------------------------------------
function AppContext(app) {
function AppContext(app) {
var prefix = fs.safeJoin(app._root, app._path);
this._prefix = prefix;
@ -88,13 +85,13 @@
this.isDevelopment = app._isDevelopment;
this.isProduction = ! app._isDevelopment;
this.manifest = app._manifest;
}
}
AppContext.prototype.foxxFilename = function (path) {
AppContext.prototype.foxxFilename = function (path) {
return fs.safeJoin(this._prefix, path);
};
};
AppContext.prototype.collectionName = function (name) {
AppContext.prototype.collectionName = function (name) {
var replaced = this.collectionPrefix.replace(/[:\.]+/g, '_') +
name.replace(/[^a-zA-Z0-9]/g, '_').replace(/(^_+|_+$)/g, '').substr(0, 64);
@ -103,24 +100,24 @@
}
return replaced;
};
};
AppContext.prototype.collection = function (name) {
AppContext.prototype.collection = function (name) {
return db._collection(this.collectionName(name));
};
};
AppContext.prototype.path = function (name) {
AppContext.prototype.path = function (name) {
return fs.join(this._prefix, name);
};
};
AppContext.prototype.comment = function (str) {
AppContext.prototype.comment = function (str) {
this.comments.push(str);
};
};
AppContext.prototype.clearComments = function () {
AppContext.prototype.clearComments = function () {
this.comments = [];
};
};
// -----------------------------------------------------------------------------
// --SECTION-- ArangoApp
@ -131,7 +128,7 @@
////////////////////////////////////////////////////////////////////////////////
function isSystemMount(mount) {
return (/^\/_/).test(mount);
return (/^\/_/).test(mount);
}
////////////////////////////////////////////////////////////////////////////////
@ -139,20 +136,20 @@ function isSystemMount(mount) {
////////////////////////////////////////////////////////////////////////////////
function computeRootAppPath(mount, isValidation) {
if (isValidation) {
if (isValidation) {
return "";
}
if (isSystemMount(mount)) {
}
if (isSystemMount(mount)) {
return module.systemAppPath();
}
return module.appPath();
}
return module.appPath();
}
////////////////////////////////////////////////////////////////////////////////
/// @brief ArangoApp constructor
////////////////////////////////////////////////////////////////////////////////
function ArangoApp(config) {
function ArangoApp(config) {
if (config.error) {
this._error = config.error;
this._isBroken = true;
@ -204,7 +201,7 @@ function computeRootAppPath(mount, isValidation) {
"Cannot read thumbnail '%s' : %s", thumbfile, err);
}
}
}
}
// -----------------------------------------------------------------------------
// --SECTION-- private methods
@ -214,9 +211,9 @@ function computeRootAppPath(mount, isValidation) {
/// @brief prints a package
////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype._PRINT = function (context) {
ArangoApp.prototype._PRINT = function (context) {
context.output += '[app "' + this._name + '" (' + this._version + ')]';
};
};
// -----------------------------------------------------------------------------
// --SECTION-- public methods
@ -226,7 +223,7 @@ function computeRootAppPath(mount, isValidation) {
/// @brief creates a Json representation of itself to be persisted
////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype.toJSON = function () {
ArangoApp.prototype.toJSON = function () {
var json = {
manifest: this._manifest,
name: this._name,
@ -252,34 +249,34 @@ function computeRootAppPath(mount, isValidation) {
}
return json;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief creates a reduced Json representation of itself for output
////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype.simpleJSON = function () {
ArangoApp.prototype.simpleJSON = function () {
var json = {
name: this._name,
version: this._version,
mount: this._mount
};
return json;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief toggles development mode
////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype.development = function(activate) {
ArangoApp.prototype.development = function(activate) {
this._isDevelopment = activate;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief set app dependencies
////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype.updateDeps = function (deps) {
ArangoApp.prototype.updateDeps = function (deps) {
var expected = this._manifest.dependencies;
var invalid = [];
@ -301,13 +298,13 @@ function computeRootAppPath(mount, isValidation) {
}, this);
return invalid;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief set app configuration
////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype.configure = function(config) {
ArangoApp.prototype.configure = function(config) {
var expected = this._manifest.configuration;
var invalid = [];
this._options.configuration = this._options.configuration || {};
@ -327,13 +324,13 @@ function computeRootAppPath(mount, isValidation) {
}, this);
return invalid;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief get app configuration
////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype.getConfiguration = function (simple) {
ArangoApp.prototype.getConfiguration = function (simple) {
var config = {};
var definitions = this._manifest.configuration;
var options = this._options.configuration;
@ -345,13 +342,13 @@ function computeRootAppPath(mount, isValidation) {
});
});
return config;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief get app dependencies
////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype.getDependencies = function(simple) {
ArangoApp.prototype.getDependencies = function(simple) {
var deps = {};
var definitions = this._manifest.dependencies;
var options = this._options.dependencies;
@ -363,13 +360,13 @@ function computeRootAppPath(mount, isValidation) {
};
});
return deps;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief App needs to be configured
////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype.needsConfiguration = function() {
ArangoApp.prototype.needsConfiguration = function() {
var config = this.getConfiguration();
var deps = this.getDependencies();
return _.any(config, function (cfg) {
@ -377,13 +374,13 @@ function computeRootAppPath(mount, isValidation) {
}) || _.any(deps, function (dep) {
return dep.current === undefined;
});
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief loadAppScript
////////////////////////////////////////////////////////////////////////////////
ArangoApp.prototype.loadAppScript = function (filename, options) {
ArangoApp.prototype.loadAppScript = function (filename, options) {
options = options || {};
var appContext = _.extend({}, options.appContext, this._context);
@ -432,10 +429,9 @@ function computeRootAppPath(mount, isValidation) {
err.cause = e;
throw err;
}
};
};
exports.ArangoApp = ArangoApp;
}());
exports.ArangoApp = ArangoApp;
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE

View File

@ -1,4 +1,4 @@
/*jshint strict: false */
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// @brief Foxx routing
@ -27,24 +27,22 @@
/// @author Copyright 2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
(function() {
'use strict';
// -----------------------------------------------------------------------------
// --SECTION-- Imports
// -----------------------------------------------------------------------------
var arangodb = require("org/arangodb");
var ArangoError = arangodb.ArangoError;
var errors = arangodb.errors;
var preprocess = require("org/arangodb/foxx/preprocessor").preprocess;
var _ = require("underscore");
var fs = require("fs");
var is = require("org/arangodb/is");
var console = require("console");
var actions = require("org/arangodb/actions");
var arangodb = require("org/arangodb");
var ArangoError = arangodb.ArangoError;
var errors = arangodb.errors;
var preprocess = require("org/arangodb/foxx/preprocessor").preprocess;
var _ = require("underscore");
var fs = require("fs");
var is = require("org/arangodb/is");
var console = require("console");
var actions = require("org/arangodb/actions");
var exportCache = {};
var exportCache = {};
// -----------------------------------------------------------------------------
// --SECTION-- private functions
@ -54,7 +52,7 @@
/// @brief excludes certain files
////////////////////////////////////////////////////////////////////////////////
var excludeFile = function (name) {
var excludeFile = function (name) {
var parts = name.split('/');
if (parts.length > 0) {
@ -67,13 +65,13 @@
}
return false;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief builds one asset of an app
////////////////////////////////////////////////////////////////////////////////
var buildAssetContent = function(app, assets, basePath) {
var buildAssetContent = function(app, assets, basePath) {
var i, j, m;
var reSub = /(.*)\/\*\*$/;
@ -132,13 +130,13 @@
}
return content;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief installs an asset for an app
////////////////////////////////////////////////////////////////////////////////
var buildFileAsset = function(app, path, basePath, asset) {
var buildFileAsset = function(app, path, basePath, asset) {
var content = buildAssetContent(app, asset.files, basePath);
var type;
@ -172,27 +170,27 @@
// .............................................................................
return { contentType: type, body: content };
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief generates asset action
////////////////////////////////////////////////////////////////////////////////
var buildAssetRoute = function (app, path, basePath, asset) {
var buildAssetRoute = function (app, path, basePath, asset) {
var c = buildFileAsset(app, path, basePath, asset);
return {
url: { match: path },
content: { contentType: c.contentType, body: c.body }
};
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief installs the assets of an app
////////////////////////////////////////////////////////////////////////////////
var installAssets = function (app, routes) {
var installAssets = function (app, routes) {
var path;
var desc = app._manifest;
@ -246,14 +244,14 @@
}
}
}
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the transform script
////////////////////////////////////////////////////////////////////////////////
var transformScript = function (file) {
var transformScript = function (file) {
if (/\.coffee$/.test(file)) {
return function (content) {
return preprocess(content, "coffee");
@ -261,13 +259,13 @@
}
return preprocess;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief create middleware matchers
////////////////////////////////////////////////////////////////////////////////
var createMiddlewareMatchers = function (rt, routes, controller, prefix) {
var createMiddlewareMatchers = function (rt, routes, controller, prefix) {
var j, route;
for (j = 0; j < rt.length; ++j) {
route = rt[j];
@ -277,13 +275,13 @@
route.context = controller;
routes.middleware.push(route);
}
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief transform the internal route objects into proper routing callbacks
////////////////////////////////////////////////////////////////////////////////
var transformControllerToRoute = function (routeInfo, route, isDevel) {
var transformControllerToRoute = function (routeInfo, route, isDevel) {
return function (req, res) {
var i, errInfo, tmp;
try {
@ -349,13 +347,13 @@
route, e.message || String(e), e.stack || "");
}
};
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief transform the internal route objects into proper routing callbacks
////////////////////////////////////////////////////////////////////////////////
var transformRoutes = function (rt, routes, controller, prefix, isDevel) {
var transformRoutes = function (rt, routes, controller, prefix, isDevel) {
var j, route;
for (j = 0; j < rt.length; ++j) {
route = rt[j];
@ -368,11 +366,11 @@
route.context = controller;
routes.routes.push(route);
}
};
};
var routeRegEx = /^(\/:?[a-zA-Z0-9_\-%]+)+\/?$/;
var routeRegEx = /^(\/:?[a-zA-Z0-9_\-%]+)+\/?$/;
var validateRoute = function(route) {
var validateRoute = function(route) {
if (route[0] !== "/") {
throw new ArangoError({
errorNum: errors.ERROR_INVALID_MOUNTPOINT.code,
@ -388,13 +386,13 @@
});
}
}
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Checks if an apps exports are already cached
////////////////////////////////////////////////////////////////////////////////
var isExported = function(mount) {
var isExported = function(mount) {
var dbname = arangodb.db._name();
if (!exportCache.hasOwnProperty(dbname)) {
exportCache[dbname] = {};
@ -404,19 +402,19 @@
return false;
}
return true;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief Checks if an apps exports are already cached
////////////////////////////////////////////////////////////////////////////////
var setIsExported = function(mount) {
var setIsExported = function(mount) {
var dbname = arangodb.db._name();
if (!exportCache.hasOwnProperty(dbname)) {
exportCache[dbname] = {};
}
exportCache[dbname][mount] = true;
};
};
// -----------------------------------------------------------------------------
// --SECTION-- public functions
@ -426,7 +424,7 @@
/// @brief computes the exports of an app
////////////////////////////////////////////////////////////////////////////////
var exportApp = function (app) {
var exportApp = function (app) {
if (app.needsConfiguration()) {
throw new ArangoError({
errorNum: errors.ERROR_APP_NEEDS_CONFIGURATION.code,
@ -454,23 +452,23 @@
setIsExported(app._mount);
return app._exports;
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief computes the exports of an app
////////////////////////////////////////////////////////////////////////////////
var invalidateExportCache = function () {
var invalidateExportCache = function () {
exportCache = {};
};
};
////////////////////////////////////////////////////////////////////////////////
///// @brief escapes all html reserved characters that are not allowed in <pre>
//////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///// @brief escapes all html reserved characters that are not allowed in <pre>
//////////////////////////////////////////////////////////////////////////////////
function escapeHTML (string) {
var list = string.split("");
var i = 0;
for (i = 0; i < list.length; ++i) {
var list = string.split("");
var i = 0;
for (i = 0; i < list.length; ++i) {
switch (list[i]) {
case "'":
list[i] = "&apos;";
@ -489,15 +487,15 @@ function escapeHTML (string) {
break;
default:
}
}
return list.join("");
}
return list.join("");
}
////////////////////////////////////////////////////////////////////////////////
/// @brief routes a default Configuration Required app
////////////////////////////////////////////////////////////////////////////////
var routeNeedsConfigurationApp = function(app) {
var routeNeedsConfigurationApp = function(app) {
return {
urlPrefix: "",
@ -537,13 +535,13 @@ function escapeHTML (string) {
foxx: true
};
};
};
////////////////////////////////////////////////////////////////////////////////
/// @brief routes this app if the original is broken app
////////////////////////////////////////////////////////////////////////////////
var routeBrokenApp = function(app, err) {
var routeBrokenApp = function(app, err) {
return {
urlPrefix: "",
@ -577,7 +575,7 @@ function escapeHTML (string) {
foxx: true
};
};
};
@ -585,7 +583,7 @@ function escapeHTML (string) {
/// @brief computes the routes of an app
////////////////////////////////////////////////////////////////////////////////
var routeApp = function (app, isInstallProcess) {
var routeApp = function (app, isInstallProcess) {
if (app.needsConfiguration()) {
return routeNeedsConfigurationApp(app);
}
@ -650,9 +648,9 @@ function escapeHTML (string) {
return routeBrokenApp(app, e);
}
return null;
};
};
var mountController = function (app, routes, mountPoint, file) {
var mountController = function (app, routes, mountPoint, file) {
validateRoute(mountPoint);
// set up a context for the application start function
@ -684,17 +682,16 @@ function escapeHTML (string) {
transformRoutes(ri.routes, routes, mountPoint, ri.urlPrefix, tmpContext.isDevelopment);
}
}
};
};
// -----------------------------------------------------------------------------
// --SECTION-- Exports
// -----------------------------------------------------------------------------
exports.exportApp = exportApp;
exports.routeApp = routeApp;
exports.invalidateExportCache = invalidateExportCache;
exports.__test_transformControllerToRoute = transformControllerToRoute;
}());
exports.exportApp = exportApp;
exports.routeApp = routeApp;
exports.invalidateExportCache = invalidateExportCache;
exports.__test_transformControllerToRoute = transformControllerToRoute;
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE

View File

@ -174,9 +174,6 @@ function Sessions(opts) {
if (opts.cookie.secret && typeof opts.cookie.secret !== 'string') {
throw new Error('Cookie secret must be a string or empty.');
}
if (!opts.cookie.name) {
opts.cookie.name = 'sid';
}
} else if (opts.type === 'header') {
if (opts.header && typeof opts.header !== 'string') {
throw new Error('Header name must be a string or empty.');

View File

@ -1,3 +1,4 @@
'use strict';
////////////////////////////////////////////////////////////////////////////////
/// @brief Foxx Swagger documentation
@ -26,28 +27,25 @@
/// @author Copyright 2015, ArangoDB GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
(function() {
'use strict';
var foxxInternal = require("org/arangodb/foxx/internals");
var _ = require("underscore");
var internal = require("internal");
var foxxInternal = require("org/arangodb/foxx/internals");
var _ = require("underscore");
var internal = require("internal");
// Wraps the docs object of a route to add swagger compatible documentation
var SwaggerDocs = function (docs, models) {
// Wraps the docs object of a route to add swagger compatible documentation
var SwaggerDocs = function (docs, models) {
this.docs = docs;
this.models = models;
};
};
SwaggerDocs.prototype.addNickname = function (httpMethod, match) {
SwaggerDocs.prototype.addNickname = function (httpMethod, match) {
this.docs.nickname = foxxInternal.constructNickname(httpMethod, match);
};
};
SwaggerDocs.prototype.addPathParam = function (paramName, description, dataType, required) {
SwaggerDocs.prototype.addPathParam = function (paramName, description, dataType, required) {
this.docs.parameters.push(foxxInternal.constructPathParamDoc(paramName, description, dataType, required));
};
};
SwaggerDocs.prototype.addQueryParam = function (paramName, description, dataType, required, allowMultiple) {
SwaggerDocs.prototype.addQueryParam = function (paramName, description, dataType, required, allowMultiple) {
this.docs.parameters.push(foxxInternal.constructQueryParamDoc(
paramName,
description,
@ -55,9 +53,9 @@
required,
allowMultiple
));
};
};
SwaggerDocs.prototype.addBodyParam = function (paramName, description, jsonSchema) {
SwaggerDocs.prototype.addBodyParam = function (paramName, description, jsonSchema) {
var token = internal.genRandomAlphaNumbers(32);
this.models[token] = jsonSchema;
@ -78,15 +76,14 @@
param.description = description;
param.dataType = token;
}
};
};
SwaggerDocs.prototype.addSummary = function (summary) {
SwaggerDocs.prototype.addSummary = function (summary) {
this.docs.summary = summary;
};
};
SwaggerDocs.prototype.addNotes = function (notes) {
SwaggerDocs.prototype.addNotes = function (notes) {
this.docs.notes = notes;
};
};
exports.Docs = SwaggerDocs;
}());