| 
									
										
										
										
											2017-04-26 20:16:47 -06:00
										 |  |  | module.exports.create = function (deps, conf) { | 
					
						
							|  |  |  |   'use strict'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   var path = require('path'); | 
					
						
							|  |  |  |   //var defaultServername = 'localhost.daplie.me';
 | 
					
						
							| 
									
										
										
										
											2017-04-27 16:27:27 -06:00
										 |  |  |   //var defaultWebRoot = '.';
 | 
					
						
							| 
									
										
										
										
											2017-04-26 20:16:47 -06:00
										 |  |  |   var assetsPath = path.join(__dirname, '..', '..', 'packages', 'assets'); | 
					
						
							| 
									
										
										
										
											2017-04-27 16:50:03 -06:00
										 |  |  |   var opts = {}; | 
					
						
							| 
									
										
										
										
											2017-04-26 20:16:47 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-27 16:50:03 -06:00
										 |  |  |   opts.global = opts.global || {}; | 
					
						
							|  |  |  |   opts.sites = opts.sites || []; | 
					
						
							| 
									
										
										
										
											2017-04-26 20:16:47 -06:00
										 |  |  |   opts.sites._map = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // argv.sites
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   opts.groups = []; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-27 19:34:13 -06:00
										 |  |  |   // 'packages', 'assets', 'com.daplie.goldilocks'
 | 
					
						
							| 
									
										
										
										
											2017-04-26 20:16:47 -06:00
										 |  |  |   opts.global = { | 
					
						
							|  |  |  |     modules: [ // TODO uh-oh we've got a mixed bag of modules (various types), a true map
 | 
					
						
							|  |  |  |       { $id: 'greenlock', email: opts.email, tos: opts.tos } | 
					
						
							|  |  |  |     , { $id: 'rvpn', email: opts.email, tos: opts.tos } | 
					
						
							|  |  |  |     //, { $id: 'content', content: content }
 | 
					
						
							|  |  |  |     , { $id: 'livereload', on: opts.livereload } | 
					
						
							|  |  |  |     , { $id: 'app', path: opts.expressApp } | 
					
						
							|  |  |  |     ] | 
					
						
							|  |  |  |   , paths: [ | 
					
						
							|  |  |  |       { $id: '/assets/', modules: [ { $id: 'serve', paths: [ assetsPath ] } ] } | 
					
						
							|  |  |  |       // TODO figure this b out
 | 
					
						
							|  |  |  |     , { $id: '/.well-known/', modules: [ | 
					
						
							|  |  |  |         { $id: 'serve', paths: [ path.join(assetsPath, 'well-known') ] } | 
					
						
							|  |  |  |       ] } | 
					
						
							|  |  |  |     ] | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   opts.defaults = { | 
					
						
							|  |  |  |     modules: [] | 
					
						
							|  |  |  |   , paths: [ | 
					
						
							| 
									
										
										
										
											2017-04-27 16:27:27 -06:00
										 |  |  |       /* | 
					
						
							| 
									
										
										
										
											2017-04-26 20:16:47 -06:00
										 |  |  |       { $id: '/', modules: [ | 
					
						
							|  |  |  |         { $id: 'serve', paths: [ defaultWebRoot ] } | 
					
						
							|  |  |  |       , { $id: 'indexes', paths: [ defaultWebRoot ] } | 
					
						
							|  |  |  |       ] } | 
					
						
							| 
									
										
										
										
											2017-04-27 16:27:27 -06:00
										 |  |  |       */ | 
					
						
							| 
									
										
										
										
											2017-04-26 20:16:47 -06:00
										 |  |  |     ] | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   opts.sites.push({ | 
					
						
							|  |  |  |     // greenlock: {}
 | 
					
						
							|  |  |  |     $id: 'localhost.alpha.daplie.me' | 
					
						
							|  |  |  |   , paths: [ | 
					
						
							| 
									
										
										
										
											2017-04-27 16:27:27 -06:00
										 |  |  |       { $id: '/', modules: [ { $id: 'serve', paths: [ path.resolve(__dirname, '..', '..', 'admin', 'public') ] } ] } | 
					
						
							|  |  |  |     , { $id: '/api/', modules: [ { $id: 'app', path: path.join(__dirname, 'admin') } ] } | 
					
						
							| 
									
										
										
										
											2017-04-26 20:16:47 -06:00
										 |  |  |     ] | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   opts.sites.push({ | 
					
						
							|  |  |  |     $id: 'localhost.daplie.invalid' | 
					
						
							|  |  |  |   , paths: [ | 
					
						
							| 
									
										
										
										
											2017-04-27 16:27:27 -06:00
										 |  |  |       { $id: '/', modules: [ { $id: 'serve', paths: [ path.resolve(__dirname, '..', '..', 'admin', 'public') ] } ] } | 
					
						
							| 
									
										
										
										
											2017-04-26 20:16:47 -06:00
										 |  |  |     , { $id: '/api/', modules: [ { $id: 'app', path: path.join(__dirname, 'admin') } ] } | 
					
						
							|  |  |  |     ] | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-27 16:50:03 -06:00
										 |  |  |   /* device, addresses, cwd, http */ | 
					
						
							|  |  |  |   var app = require('../app.js')(deps, conf, opts); | 
					
						
							| 
									
										
										
										
											2017-04-26 20:16:47 -06:00
										 |  |  |   var http = require('http'); | 
					
						
							|  |  |  |   return http.createServer(app); | 
					
						
							|  |  |  | }; |