hapijs / glue

Server composer for hapi.js
Other
245 stars 62 forks source link

manifest limitation on server options #2

Closed csrl closed 9 years ago

csrl commented 9 years ago

Glue restricts what is passed as options to new Hapi.Server(options), only allowing 'app', 'debug' and 'cache' members to the options.

It'd be useful to be able to define the full server options that are available.

csrl commented 9 years ago

May I suggest a change something to the affect of:

diff --git a/lib/index.js b/lib/index.js
index 5fef30a..22b555b 100755
--- a/lib/index.js
+++ b/lib/index.js
@@ -13,19 +13,8 @@ var internals = {};

 internals.schema = Joi.object({
-    server: Joi.object({
-        app: Joi.object().allow(null),
-        debug: Joi.object({
-            request: Joi.array().allow(false)
-        }).allow(false),
-        cache: Joi.alternatives([
-            Joi.string(),
-            Joi.object(),
-            Joi.func(),
-            Joi.array().includes(Joi.object()).min(1)
-        ]).allow(null)
-    }),
-    connections: Joi.array().required().min(1),
+    server: Joi.object(),
+    connections: Joi.array(),
     plugins: Joi.object()
 });

@@ -114,8 +103,12 @@ exports.compose = function (manifest /*, [options], callback */) {
     var server = new Hapi.Server(packSettings);

     // Load connections
+    var connections = manifest.connections;
+    if (0 === connections.length) {
+        connections.push({});
+    }

-    manifest.connections.forEach(function (connection) {
+    connections.forEach(function (connection) {

         server.connection(connection);
     });
lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.