Skip to content

Commit

Permalink
Also allow for service workers.
Browse files Browse the repository at this point in the history
  • Loading branch information
martindale committed Aug 3, 2015
1 parent 74398b0 commit 7794dda
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/Service/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var HTTP = function() {
this._post = {};
this._plugins = [];
this._scripts = [];
this._workers = [];
};

require('util').inherits( HTTP , Service );
Expand Down Expand Up @@ -288,6 +289,7 @@ HTTP.prototype.attach = function( maki ) {
if (plugin.setup) plugin.setup( maki );
if (plugin.middleware) maki.app.use( plugin.middleware );
if (plugin.client) self._scripts.push( plugin.client );
if (plugin.worker) self._workers.push( plugin.worker );
});

maki.app.use(function(req, res, next) {
Expand Down Expand Up @@ -770,6 +772,15 @@ HTTP.prototype.start = function( started ) {
browserify.bundle().pipe(bundle);
});

// TODO: build an extensible service worker platform; events, triggers, etc.
self._workers.forEach(function(w) {
var workerPath = __dirname + '/../../public/service.js'; // sadly at root :(
var worker = fs.createWriteStream(workerPath);
worker.on('open', function() {
fs.createReadStream(w).pipe(worker);
});
});


// TODO: spdy/https should be the default. Make it so, with optional http.
// TODO: allow configurable certificate, supplied by config
Expand Down

0 comments on commit 7794dda

Please sign in to comment.