screen sharinggit add .!
[henge/kiak.git] / router.js
diff --git a/router.js b/router.js
new file mode 100644 (file)
index 0000000..2f0441a
--- /dev/null
+++ b/router.js
@@ -0,0 +1,22 @@
+/**
+ * @file      HTTP(S) Router that treats the first directory in a URL's path as
+ *            a route to a host.
+ * @author    Ken Grimes
+ * @version   0.0.1
+ * @license   AGPL-3.0
+ * @copyright jk software 2017
+ */
+const fs = require('fs')
+
+module.exports = (opts) => {
+  const startHttpd = (listener) => {
+    if (opts['no-tls'])
+      return require('http').createServer(listener)
+    if (fs.existsSync(opts['ca-cert']))
+      
+  }
+  return {
+    httpd: startHttpd(),
+    wsd:   startWsd()
+  }
+}