Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.wrap = function(view, appname) {
var view_split = view.split('.'),
target = require(view_split[0]),
appInstance = application.getApplicationInstance(appname);
for(var i = 1, len = view_split.length; i < len; ++i) {
target = target[view_split[i]];
}
return function() {
return target.apply(appInstance, Array.prototype.slice.call(arguments));
};
};
Object.keys(middleware).forEach(function(name) {
output_middleware[name] = createWrappedMethod(instance, middleware[name]);
});
output_middleware.toString = function() {
return "";
};
return output_middleware;
};
for(var i = 0, len = middleware_strings.length; i < len; ++i) {
var split = middleware_strings[i].split(':'),
app = split[0],
rest = split.slice(1).join(':'),
appInstance = application.getApplicationInstance(app);
middleware.push(createWrappedMiddleware(appInstance, appInstance.app.middleware[rest], rest));
}
return function(request, response) {
var wilsonRequest = new http.HttpRequest(request, response, middleware);
wilsonRequest.attemptContinue();
};
};
exports.runcommand = function() {
var sys = require('sys'),
conf = require('wilson/conf'),
core = require('wilson/core/app'),
application = require('wilson/application'),
app_and_command = process.argv[2].split(':'),
app = app_and_command[0],
command = app_and_command[1],
appInstance;
try {
application.loadApps(conf.settings.APP_OVERRIDES);
appInstance = application.getApplicationInstance(app);
} catch(err) {
conf.setSettings({
INSTALLED_APPS:{
core:application.use('wilson/core')
},
TEMPLATE_LOADERS:[
'wilson/template/loaders.application',
'wilson/template/loaders.filesystem',
],
});
application.loadApps(conf.settings.APP_OVERRIDES);
appInstance = application.getApplicationInstance('core');
}
if(appInstance) {
var appCommand = appInstance.app.commands[command];
try {
application.loadApps(conf.settings.APP_OVERRIDES);
appInstance = application.getApplicationInstance(app);
} catch(err) {
conf.setSettings({
INSTALLED_APPS:{
core:application.use('wilson/core')
},
TEMPLATE_LOADERS:[
'wilson/template/loaders.application',
'wilson/template/loaders.filesystem',
],
});
application.loadApps(conf.settings.APP_OVERRIDES);
appInstance = application.getApplicationInstance('core');
}
if(appInstance) {
var appCommand = appInstance.app.commands[command];
if(appCommand) {
appCommand.apply(appInstance, process.argv.slice(3));
} else {
sys.puts('Could not find the command '+app_and_command);
if(app === appInstance.name) {
sys.puts('Available commands within '+app);
for(var command_name in appInstance.app.commands) {
sys.puts('\t'+[app, command_name].join(':'));
}
} else {
sys.puts('All apps and commands:');
var appInstances = application.getApplicationInstances();
exports.app = function(regex, app_name, instance) {
var app_instance = instance || application.getApplicationInstance(app_name),
routes = app_instance.app.urls.routes,
routes_out = [];
for(var i = 0, len = routes.length; i < len; ++i) {
routes_out.push(new escaperoute.Route(
routes[i].re.source,
routes[i].target,
[app_instance.name,routes[i].name].join(':')
));
}
app_instance.urls = new escaperoute.Router(
app_instance.app.urls.base_path,
routes_out,
app_instance
);