mirror of
				https://github.com/therootcompany/greenlock-express.js.git
				synced 2024-11-16 17:28:59 +00:00 
			
		
		
		
	allow without callbacks, issue #9
This commit is contained in:
		
							parent
							
								
									4e9a6c0719
								
							
						
					
					
						commit
						bd5ee84e25
					
				@ -22,9 +22,14 @@ GLE.init = function(fn) {
 | 
				
			|||||||
        return require("./worker.js").create();
 | 
					        return require("./worker.js").create();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var opts = fn();
 | 
					    var opts;
 | 
				
			||||||
 | 
					    if ("function" === typeof fn) {
 | 
				
			||||||
 | 
					        opts = fn();
 | 
				
			||||||
 | 
					    } else if ("object" === typeof fn) {
 | 
				
			||||||
 | 
					        opts = fn;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (!opts || "object" !== typeof opts) {
 | 
					    if (!opts || "object" !== typeof opts) {
 | 
				
			||||||
        throw new Error("the `Greenlock.init(fn)` function should return an object `{ greenlock, cluster }`");
 | 
					        throw new Error("the `Greenlock.init(fn)` function should return an object `{ packageRoot, cluster }`");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // just for ironic humor
 | 
					    // just for ironic humor
 | 
				
			||||||
 | 
				
			|||||||
@ -48,10 +48,12 @@ Master.create = function(opts) {
 | 
				
			|||||||
            kickoff();
 | 
					            kickoff();
 | 
				
			||||||
            resolveCb(fn);
 | 
					            resolveCb(fn);
 | 
				
			||||||
            return master;
 | 
					            return master;
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        serve: function(fn) {
 | 
				
			||||||
 | 
					            // ignore
 | 
				
			||||||
 | 
					            master.ready(fn);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    // backwards compat starts early...
 | 
					 | 
				
			||||||
    master.serve = master.ready;
 | 
					 | 
				
			||||||
    return master;
 | 
					    return master;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										11
									
								
								single.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								single.js
									
									
									
									
									
								
							@ -19,6 +19,17 @@ Single.create = function(opts) {
 | 
				
			|||||||
            // ignore
 | 
					            // ignore
 | 
				
			||||||
            //fn(master);
 | 
					            //fn(master);
 | 
				
			||||||
            return single;
 | 
					            return single;
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        serve: function(fn) {
 | 
				
			||||||
 | 
					            // keeping backwards compat
 | 
				
			||||||
 | 
					            if (1 === fn.length) {
 | 
				
			||||||
 | 
					                single.ready(fn);
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            // serving the app, right away
 | 
				
			||||||
 | 
					            single.ready(function(glx) {
 | 
				
			||||||
 | 
					                glx.serveApp(fn);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    // backwards compat starts now
 | 
					    // backwards compat starts now
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										11
									
								
								worker.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								worker.js
									
									
									
									
									
								
							@ -22,6 +22,17 @@ Worker.create = function() {
 | 
				
			|||||||
        master: function() {
 | 
					        master: function() {
 | 
				
			||||||
            // ignore
 | 
					            // ignore
 | 
				
			||||||
            return worker;
 | 
					            return worker;
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        serve: function(fn) {
 | 
				
			||||||
 | 
					            // keeping backwards compat
 | 
				
			||||||
 | 
					            if (1 === fn.length) {
 | 
				
			||||||
 | 
					                worker.ready(fn);
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            // serving the express app, right away
 | 
				
			||||||
 | 
					            worker.ready(function(glx) {
 | 
				
			||||||
 | 
					                glx.serveApp(fn);
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    // backwards compat starts early...
 | 
					    // backwards compat starts early...
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user