Skip to content

Commit

Permalink
feat(service): Now express app can be mounted even if sw is already a…
Browse files Browse the repository at this point in the history
…ctive
  • Loading branch information
jjak0b committed Mar 24, 2021
1 parent 9f6cba8 commit 3eb235e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ class Server {
this.serverApp = express();
this.port = 80;
this.registerService();

this.promiseMount
.then( (app) => {
if(!this.mountUrl) {
this.mountUrl = new Url( self.registration.scope );
}
let mountPath = this.mountUrl.pathname;
this.serverApp.all( "*", mountExpressAt( mountPath ) );
this.serverApp.use( this.mountUrl.pathname, app )
debug("Mounted app @", this.mountUrl.toString() );
})
}

registerService() {
Expand All @@ -46,14 +57,7 @@ class Server {
this.mountUrl = new Url( self.registration.scope );
let mountPath = this.mountUrl.pathname;

this.serverApp.all( "*", mountExpressAt( mountPath ) );
debug('installed at mount: \"%s\"', mountPath, self.registration );

this.promiseMount
.then( (app) => {
this.serverApp.use( this.mountUrl.pathname, app )
debug("Mounted app @", this.mountUrl.toString() );
})
}

onActivate(event) {
Expand Down

0 comments on commit 3eb235e

Please sign in to comment.