1
0
Fork 0

Removed appId and inserted a action stub to register the routing table for one foxx app.

This commit is contained in:
Michael Hackstein 2015-01-19 15:52:41 +01:00
parent 873a5b409e
commit 1e4ba6e09b
5 changed files with 563 additions and 538 deletions

View File

@ -2144,10 +2144,18 @@ function stringifyRequestAddress (req) {
return out;
}
function setFoxxRouting(mount, routes) {
}
// -----------------------------------------------------------------------------
// --SECTION-- MODULE EXPORTS
// -----------------------------------------------------------------------------
// Insert the routing information for one foxx application
exports.setFoxxRouting = setFoxxRouting;
// load all actions from the actions directory
exports.startup = startup;

View File

@ -55,7 +55,6 @@
this.comments = [];
this.name = app._name;
this.version = app._version;
this.appId = app._id;
this.mount = app._mount;
this.collectionPrefix = app._collectionPrefix;
this.options = app._options;
@ -108,7 +107,6 @@
////////////////////////////////////////////////////////////////////////////////
var ArangoApp = function (config) {
this._id = config.id; // ???
this._manifest = config.manifest;
this._name = config.manifest.name;
this._version = config.manifest.version;
@ -121,6 +119,10 @@ var ArangoApp = function (config) {
this._exports = {};
this._collectionPrefix = this._mount.substr(1).replace(/-/g, "_").replace(/\//g, "_") + "_";
this._context = new AppContext(this);
if (this._manifest.hasOwnProperty("defaultDocument")) {
this._manifest.defaultDocument = "index.html";
}
};
// -----------------------------------------------------------------------------
@ -145,7 +147,6 @@ var ArangoApp = function (config) {
ArangoApp.prototype.toJSON = function () {
var json = {
id: this._id,
manifest: this._manifest,
name: this._name,
version: this._version,

View File

@ -101,7 +101,6 @@ Controller = function (context, options) {
options: {
name: context.name,
version: context.version,
appId: context.appId,
mount: context.mount,
isDevelopment: context.isDevelopment,
isProduction: context.isProduction,

View File

@ -526,7 +526,7 @@ var scanFoxx = function(mount, options) {
utils.tmp_getStorage().save(app.toJSON());
var routes = routeApp(app);
require("console").log("Routes", Object.keys(routes));
// TODO Routing?
// TODO Routing weiter?
};
@ -638,6 +638,25 @@ var upgrade = function(appInfo, mount, options) {
_install(appInfo, mount, options, false);
};
////////////////////////////////////////////////////////////////////////////////
/// @brief initializes the Foxx apps
////////////////////////////////////////////////////////////////////////////////
var initializeFoxx = function() {
appCache = {};
var cursor = utils.tmp_getStorage().all();
var config, app;
while (cursor.hasNext()) {
config = cursor.next();
app = new ArangoApp(config);
appCache[app._mount] = app;
var routes = routeApp(app);
require("console").log("Routes", Object.keys(routes));
// TODO Routing weiter?
}
};
// -----------------------------------------------------------------------------
// --SECTION-- exports
// -----------------------------------------------------------------------------
@ -676,9 +695,7 @@ exports.searchJson = store.searchJson;
exports.update = store.update;
exports.info = store.info;
// TODO implement!!
exports.initializeFoxx = function () {};
exports.initializeFoxx = initializeFoxx;
}());
// -----------------------------------------------------------------------------

View File

@ -39,6 +39,7 @@
var fs = require("fs");
var frontendDevelopmentMode = require("internal").frontendDevelopmentMode;
var console = require("console");
var setFoxxRouting = require("org/arangodb/actions").setFoxxRouting;
// -----------------------------------------------------------------------------
// --SECTION-- private functions
@ -297,7 +298,7 @@
var i;
var mount = app._mount;
var defaultDocument = app._manifest.defaultDocument; // TODO by default "index.html"
var defaultDocument = app._manifest.defaultDocument;
// setup the routes
var routes = {
@ -364,11 +365,9 @@
if (controllers.hasOwnProperty(i)) {
file = controllers[i];
// TODO ????
// set up a context for the application start function
tmpContext = {
prefix: arangodb.normalizeURL("/" + i), // app mount
routingInfo: {},
foxxes: []
};
@ -423,6 +422,7 @@
// install all files and assets
installAssets(app, routes);
setFoxxRouting(app._mount, routes);
// and return all routes
return routes;
}