2015-02-06 23:45:28 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-01-30 01:10:49 +00:00
|
|
|
var Activity = require('./src/Activity');
|
2015-02-06 23:45:28 +00:00
|
|
|
var Server = require('./src/Server');
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2015-02-06 23:45:28 +00:00
|
|
|
exports.middleware = function(options) {
|
|
|
|
var server = new Server(options);
|
|
|
|
return server.processRequest.bind(server);
|
2015-01-30 01:10:49 +00:00
|
|
|
};
|
|
|
|
|
2015-02-06 23:45:28 +00:00
|
|
|
exports.buildPackageFromUrl = function(options, reqUrl) {
|
|
|
|
Activity.disable();
|
2015-02-19 01:51:14 +00:00
|
|
|
// Don't start the filewatcher or the cache.
|
|
|
|
if (options.nonPersistent == null) {
|
|
|
|
options.nonPersistent = true;
|
|
|
|
}
|
|
|
|
|
2015-02-06 23:45:28 +00:00
|
|
|
var server = new Server(options);
|
|
|
|
return server.buildPackageFromUrl(reqUrl)
|
|
|
|
.then(function(p) {
|
2015-02-19 01:51:14 +00:00
|
|
|
server.end();
|
2015-02-06 23:45:28 +00:00
|
|
|
return p;
|
|
|
|
});
|
2015-01-30 01:10:49 +00:00
|
|
|
};
|
2015-02-19 01:51:14 +00:00
|
|
|
|
|
|
|
exports.getDependencies = function(options, main) {
|
|
|
|
Activity.disable();
|
|
|
|
// Don't start the filewatcher or the cache.
|
|
|
|
if (options.nonPersistent == null) {
|
|
|
|
options.nonPersistent = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
var server = new Server(options);
|
|
|
|
return server.getDependencies(main)
|
|
|
|
.then(function(r) {
|
|
|
|
server.end();
|
|
|
|
return r.dependencies;
|
|
|
|
});
|
|
|
|
};
|