mirror of https://gitee.com/bigwinds/arangodb
simplified options
This commit is contained in:
parent
520d2b7294
commit
2a30b068bf
|
@ -258,7 +258,8 @@ function executeAppScript (app, name, mount, prefix) {
|
||||||
appModule: app.createAppModule(),
|
appModule: app.createAppModule(),
|
||||||
isDevelopment: devel,
|
isDevelopment: devel,
|
||||||
isProduction: ! devel,
|
isProduction: ! devel,
|
||||||
options: app._options
|
options: app._options,
|
||||||
|
basePath: root
|
||||||
};
|
};
|
||||||
|
|
||||||
var cp = appContext.collectionPrefix;
|
var cp = appContext.collectionPrefix;
|
||||||
|
@ -471,9 +472,14 @@ function routingAalApp (app, mount, options) {
|
||||||
if (apps.hasOwnProperty(i)) {
|
if (apps.hasOwnProperty(i)) {
|
||||||
var file = apps[i];
|
var file = apps[i];
|
||||||
var devel = false;
|
var devel = false;
|
||||||
|
var root;
|
||||||
|
|
||||||
if (app._id.substr(0,4) === "dev:") {
|
if (app._id.substr(0,4) === "dev:") {
|
||||||
devel = true;
|
devel = true;
|
||||||
|
root = module.devAppPath();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
root = module.appPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up a context for the application start function
|
// set up a context for the application start function
|
||||||
|
@ -486,6 +492,7 @@ function routingAalApp (app, mount, options) {
|
||||||
collectionPrefix: prefix, // collection prefix
|
collectionPrefix: prefix, // collection prefix
|
||||||
appModule: app.createAppModule(), // app module
|
appModule: app.createAppModule(), // app module
|
||||||
options: options,
|
options: options,
|
||||||
|
basePath: root,
|
||||||
|
|
||||||
isDevelopment: devel,
|
isDevelopment: devel,
|
||||||
isProduction: ! devel,
|
isProduction: ! devel,
|
||||||
|
|
|
@ -125,8 +125,6 @@ Application = function (context, options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.isDevelopment = context.isDevelopment;
|
|
||||||
this.isProduction = context.isProduction;
|
|
||||||
this.helperCollection = {};
|
this.helperCollection = {};
|
||||||
this.routingInfo.urlPrefix = urlPrefix;
|
this.routingInfo.urlPrefix = urlPrefix;
|
||||||
|
|
||||||
|
@ -144,16 +142,14 @@ Application = function (context, options) {
|
||||||
action: {
|
action: {
|
||||||
callback: myMiddleware.stringRepresentation,
|
callback: myMiddleware.stringRepresentation,
|
||||||
options: {
|
options: {
|
||||||
|
name: context.name,
|
||||||
|
version: context.version,
|
||||||
|
appId: context.appId,
|
||||||
|
mount: context.mount,
|
||||||
isDevelopment: context.isDevelopment,
|
isDevelopment: context.isDevelopment,
|
||||||
isProduction: context.isProduction,
|
isProduction: context.isProduction,
|
||||||
app: {
|
prefix: context.prefix,
|
||||||
appId: context.appId,
|
options: context.options
|
||||||
name: context.name,
|
|
||||||
version: context.version,
|
|
||||||
mount: context.mount,
|
|
||||||
prefix: context.prefix,
|
|
||||||
options: context.options
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,7 +405,7 @@ _.extend(Application.prototype, {
|
||||||
this.routingInfo.middleware.push({
|
this.routingInfo.middleware.push({
|
||||||
url: {match: path},
|
url: {match: path},
|
||||||
action: {
|
action: {
|
||||||
callback: "function (req, res, opts, next) { " + String(func) + "(req, res); next(); }"
|
callback: "(function (req, res, opts, next) { (" + String(func) + "(req, res, opts)); next(); })"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -442,7 +438,7 @@ _.extend(Application.prototype, {
|
||||||
this.routingInfo.middleware.push({
|
this.routingInfo.middleware.push({
|
||||||
url: {match: path},
|
url: {match: path},
|
||||||
action: {
|
action: {
|
||||||
callback: "function (req, res, opts, next) { next(); " + String(func) + "(req, res); }"
|
callback: "(function (req, res, opts, next) { next(); (" + String(func) + "(req, res, opts)); })"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -855,35 +851,34 @@ BaseMiddleware = function (templateCollection, helperCollection) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var trace = options.isDevelopment;
|
var trace = options.isDevelopment;
|
||||||
if (!trace && options.hasOwnProperty("app") && options.app.hasOwnProperty("options")) {
|
if (!trace && options.hasOwnProperty("options")) {
|
||||||
trace = options.app.options.trace;
|
trace = options.options.trace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (trace) {
|
if (trace) {
|
||||||
console.log("%s, incoming request from %s: %s",
|
console.log("%s, incoming request from %s: %s",
|
||||||
options.app.mount,
|
options.mount,
|
||||||
request.client.address,
|
request.client.address,
|
||||||
actions.stringifyRequestAddress(request));
|
actions.stringifyRequestAddress(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
request = _.extend(request, requestFunctions);
|
_.extend(request, requestFunctions);
|
||||||
response = _.extend(response, responseFunctions);
|
_.extend(response, responseFunctions);
|
||||||
next();
|
next();
|
||||||
if (trace) {
|
if (trace) {
|
||||||
if (response.hasOwnProperty("body")) {
|
if (response.hasOwnProperty("body")) {
|
||||||
console.log("%s, outgoing response of type %s, body length: %d",
|
console.log("%s, outgoing response of type %s, body length: %d",
|
||||||
options.app.mount,
|
options.mount,
|
||||||
response.contentType,
|
response.contentType,
|
||||||
parseInt(response.body.length, 10));
|
parseInt(response.body.length, 10));
|
||||||
} else if (response.hasOwnProperty("bodyFromFile")) {
|
} else if (response.hasOwnProperty("bodyFromFile")) {
|
||||||
console.log("%s, outgoing response of type %s, body file: %s",
|
console.log("%s, outgoing response of type %s, body file: %s",
|
||||||
options.app.mount,
|
options.mount,
|
||||||
response.contentType,
|
response.contentType,
|
||||||
response.bodyFromFile);
|
response.bodyFromFile);
|
||||||
} else {
|
} else {
|
||||||
console.log("%s, outgoing response of type %s, no body",
|
console.log("%s, outgoing response of type %s, no body",
|
||||||
options.app.mount,
|
options.mount,
|
||||||
response.contentType);
|
response.contentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue