New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

glue

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glue - npm Package Compare versions

Comparing version 2.4.0 to 3.0.0

API.md

143

lib/index.js

@@ -0,8 +1,9 @@

'use strict';
// Load modules
var Path = require('path');
var Hapi = require('hapi');
var Hoek = require('hoek');
var Items = require('items');
var Joi = require('joi');
const Path = require('path');
const Hapi = require('hapi');
const Hoek = require('hoek');
const Items = require('items');
const Joi = require('joi');

@@ -12,3 +13,3 @@

var internals = {};
const internals = {};

@@ -20,8 +21,14 @@

preConnections: Joi.func().allow(false),
prePlugins: Joi.func().allow(false)
preRegister: Joi.func().allow(false)
}),
manifest: Joi.object({
server: Joi.object(),
connections: Joi.array().min(1),
plugins: [Joi.object(), Joi.array()]
connections: Joi.array(Joi.object()),
registrations: Joi.array().items(Joi.object({
plugin: [
Joi.string(),
Joi.object({ register: Joi.string(), options: Joi.any().optional() })
],
options: Joi.object()
}))
})

@@ -33,4 +40,4 @@ };

var options = arguments.length === 2 ? {} : arguments[1];
var callback = arguments.length === 2 ? arguments[1] : arguments[2];
const options = arguments.length === 2 ? {} : arguments[1];
const callback = arguments.length === 2 ? arguments[1] : arguments[2];

@@ -43,7 +50,7 @@ Hoek.assert(typeof callback === 'function', 'Invalid callback');

var serverOpts = internals.parseServer(manifest.server || {}, options.relativeTo);
var server = new Hapi.Server(serverOpts);
const serverOpts = internals.parseServer(manifest.server || {}, options.relativeTo);
const server = new Hapi.Server(serverOpts);
var steps = [];
steps.push(function (next) {
const steps = [];
steps.push((next) => {

@@ -58,8 +65,8 @@ if (options.preConnections) {

steps.push(function (next) {
steps.push((next) => {
// Load connections
if (manifest.connections) {
manifest.connections.forEach(function (connection) {
if (manifest.connections && manifest.connections.length > 0) {
manifest.connections.forEach((connection) => {

@@ -76,6 +83,6 @@ server.connection(connection);

steps.push(function (next) {
steps.push((next) => {
if (options.prePlugins) {
options.prePlugins(server, next);
if (options.preRegister) {
options.preRegister(server, next);
}

@@ -87,38 +94,28 @@ else {

steps.push(function (next) {
steps.push((next) => {
// Load plugins
// Load registrations
var plugins = [];
var parsed;
if (manifest.registrations) {
const registrations = manifest.registrations.map((reg) => {
if (Array.isArray(manifest.plugins)) {
for (var i = 0, l = manifest.plugins.length; i < l; i++) {
var pluginObject = manifest.plugins[i];
var keys = Object.keys(pluginObject);
return {
plugin: internals.parsePlugin(reg.plugin, options.relativeTo),
options: reg.options || {}
};
});
Items.serial(registrations, (reg, nextRegister) => {
Hoek.assert(keys.length === 1, 'Invalid plugin config');
parsed = internals.parsePlugin(keys[0], pluginObject[keys[0]], options.relativeTo);
plugins = plugins.concat(parsed);
}
server.register(reg.plugin, reg.options, nextRegister);
}, next);
}
else {
Object.keys(manifest.plugins || {}).forEach(function (name) {
parsed = internals.parsePlugin(name, manifest.plugins[name], options.relativeTo);
plugins = plugins.concat(parsed);
});
next();
}
Items.serial(plugins, function (plugin, nextRegister) {
server.register(plugin.module, plugin.apply, nextRegister);
}, next);
});
Items.serial(steps, function (step, nextStep) {
Items.serial(steps, (step, nextStep) => {
step(nextStep);
}, function (err) {
}, (err) => {

@@ -139,12 +136,12 @@ if (err) {

var caches = [];
var config = [].concat(server.cache);
for (var i = 0, il = config.length; i < il; ++i) {
var item = config[i];
const caches = [];
const config = [].concat(server.cache);
for (let i = 0; i < config.length; ++i) {
let item = config[i];
if (typeof item === 'string') {
item = { engine: item };
}
if (typeof item.engine === 'string') {
var strategy = item.engine;
let strategy = item.engine;
if (relativeTo && strategy[0] === '.') {

@@ -167,5 +164,10 @@ strategy = Path.join(relativeTo, strategy);

internals.parsePlugin = function (name, plugin, relativeTo) {
internals.parsePlugin = function (plugin, relativeTo) {
var path = name;
plugin = Hoek.clone(plugin);
if (typeof plugin === 'string') {
plugin = { register: plugin };
}
let path = plugin.register;
if (relativeTo && path[0] === '.') {

@@ -175,33 +177,4 @@ path = Path.join(relativeTo, path);

if (Array.isArray(plugin)) {
var plugins = [];
Hoek.assert(plugin.length > 0, 'Invalid plugin configuration');
plugin.forEach(function (instance) {
Hoek.assert(typeof instance === 'object', 'Invalid plugin configuration');
var registerOptions = Hoek.cloneWithShallow(instance, 'options');
delete registerOptions.options;
plugins.push({
module: {
register: require(path),
options: instance.options
},
apply: registerOptions
});
});
return plugins;
}
return {
module: {
register: require(path),
options: plugin
},
apply: {}
};
plugin.register = require(path);
return plugin;
};
{
"name": "glue",
"description": "Server composer for hapi.js",
"version": "2.4.0",
"version": "3.0.0",
"repository": {

@@ -18,15 +18,15 @@ "type": "git",

"engines": {
"node": ">=0.10.32"
"node": ">=4.0"
},
"dependencies": {
"boom": "2.x.x",
"hapi": "8.x.x || 9.x.x || 10.x.x || 11.x.x",
"hoek": "2.x.x",
"items": "1.x.x",
"joi": "5.x.x || 6.x.x"
"boom": "3.x.x",
"hapi": "11.x.x",
"hoek": "3.x.x",
"items": "2.x.x",
"joi": "7.x.x"
},
"devDependencies": {
"catbox-memory": "1.x.x",
"code": "1.x.x",
"lab": "5.x.x"
"catbox-memory": "2.x.x",
"code": "2.x.x",
"lab": "7.x.x"
},

@@ -33,0 +33,0 @@ "scripts": {

@@ -1,141 +0,27 @@

# glue
## glue
Server composer for hapi.js.
[![Build Status](https://travis-ci.org/hapijs/glue.svg)](https://travis-ci.org/hapijs/glue)
[![Build Status](https://travis-ci.org/hapijs/glue.svg?branch=master)](https://travis-ci.org/hapijs/glue)
Lead Maintainer - [Chris Rempel](https://github.com/csrl)
## Interface
### A server composer for hapi.js.
Glue exports a single function `compose` accepting a JSON `manifest` file specifying the Hapi server options, connections and plugins. Glue primarily works in synergy with [Rejoice](https://github.com/hapijs/rejoice), but can be integrated directly into any Hapi application loader.
Glue provides configuration based composition of hapi's Server object. Specifically it wraps
- `compose(manifest, [options], callback)`
+ `manifest` - an object having:
* 'server' - an object containing the options passed to [`new Server([options])`](http://hapijs.com/api#new-serveroptions)
* 'connections' - an array of connection options, passed individually in calls to [`server.connection([options])`](http://hapijs.com/api#serverconnectionoptions)
* 'plugins' - an object or array of objects holding plugin entries to register with [`server.register(plugin, [options], callback)`](http://hapijs.com/api#serverregisterplugins-options-callback). Each object key is the `name` of the plugin to load and register and the value is one of:
+ an object to use as the plugin options which get passed to the plugin's registration function when called.
+ an array of objects where each object will load a separate instance of the plugin. Multiple instances of a plugin is only possible if supported by the plugin ie. the plugin is implemented with `attributes.multiple` as `true`. Each object can have:
* any option from [`server.register`](http://hapijs.com/api#serverregisterplugins-options-callback) options
* `options` - an object to use as the plugin options which get passed to the plugin's registration function when called.
+ `options` - an object having
* 'relativeTo' - a file-system path string that is used to resolve loading modules with `require`. Used in `server.cache` and `plugins[name]`
* 'preConnections' - a callback function that is called prior to adding connections to the server. The function signature is `function (server, next)` where:
+ `server` - is the server object returned from `new Server(options)`.
+ `next`- the callback function the method must call to return control over to glue
* 'prePlugins' - a callback function that is called prior to registering plugins with the server. The function signature is `function (server, next)` where:
+ `server` - is the server object with all connections selected.
+ `next`- the callback function the method must call to return control over to glue
+ `callback` - the callback function with signature `function (err, server)` where:
* `err` - the error response if a failure occurred, otherwise `null`.
* `server` - the server object. Call `server.start()` to actually start the server.
* `server = new Hapi.Server(Options)`
* one or more `server.connection(Options)`
* zero or more `server.register(Plugin, Options)`
### Notes
calling each based on the configuration generated from the Glue manifest.
When using an an object as the value for the `manifest.plugins` field, the order of plugin registration is not guaranteed. When using an array as the value, then the plugin registration order follows the array order. If you are developing a plugin, you should ensure your plugin dependencies are properly managed to guarantee that all dependencies are loaded before your plugin registration completes. See [`server.dependency(dependencies, [after])`](http://hapijs.com/api#serverdependencydependencies-after) for more information.
### Interface
## Usage
Glue's [API](API.md) is a single function `compose` accepting a JSON `manifest` file specifying the hapi server options, connections, and registrations.
```javascript
var Glue = require('glue');
### hapi version dependency
var manifest = {
server: {
cache: 'redis'
},
connections: [
{
port: 8000,
labels: ['web']
},
{
port: 8001,
labels: ['admin']
}
],
plugins: [
{'./assets': {
uglify: true
}},
{'./ui-user': [
{
select: ['web'],
options: { }
}
]},
{'./ui-admin': [
{
select: ['admin'],
routes: {
prefix: '/admin'
},
options: {
sessiontime: 500
}
}
]}
]
};
Glue can support different versions of hapi. Adding support for a new version of hapi is considered a `minor` change. Removing support for a version of hapi is considered a `major` change.
var options = {
relativeTo: __dirname
};
By default NPM will resolve Glue's dependency on hapi using the most recent supported version of hapi. To force a specific supported hapi version for your project, include hapi in your package dependencies along side of Glue.
Glue.compose(manifest, options, function (err, server) {
if (err) {
throw err;
}
server.start(function () {
console.log('Hapi days!');
});
});
```
The above is translated into the following equivalent Hapi API calls.
```javascript
var server = Hapi.Server({cache: [{engine: require('redis')}]});
server.connection({
port: 8000,
labels: ['web']
});
server.connection({
port: 8001,
labels: ['admin']
});
var pluginPath, pluginOptions, registerOptions;
pluginPath = Path.join(__dirname, './assets');
pluginOptions = {uglify: true};
registerOptions = {};
server.register({register: require(pluginPath), options: pluginOptions}, registerOptions, function (err) {
if (err) {
throw err;
}
pluginPath = Path.join(__dirname, './ui-user');
pluginOptions = {};
registerOptions = {select: ['web']};
server.register({register: require(pluginPath), options: pluginOptions}, registerOptions, function (err) {
if (err) {
throw err;
}
pluginPath = Path.join(__dirname, './ui-admin');
pluginOptions = {sessiontime: 500};
registerOptions = {select: ['admin'], routes: {prefix: '/admin'}};
server.register({register: require(pluginPath), options: pluginOptions}, registerOptions, function (err) {
if (err) {
throw err;
}
server.start(function () {
console.log('Hapi days!');
});
});
});
});
```
Glue currently supports hapi **11**.

@@ -0,6 +1,7 @@

'use strict';
// Load modules
var Code = require('code');
var Glue = require('..');
var Lab = require('lab');
const Code = require('code');
const Glue = require('..');
const Lab = require('lab');

@@ -10,3 +11,3 @@

var internals = {};
const internals = {};

@@ -16,15 +17,15 @@

var lab = exports.lab = Lab.script();
var describe = lab.describe;
var it = lab.it;
var expect = Code.expect;
const lab = exports.lab = Lab.script();
const describe = lab.describe;
const it = lab.it;
const expect = Code.expect;
describe('compose()', function () {
describe('compose()', () => {
it('composes server with an empty manifest', function (done) {
it('composes a server with an empty manifest', (done) => {
var manifest = {};
const manifest = {};
Glue.compose(manifest, function (err, server) {
Glue.compose(manifest, (err, server) => {

@@ -37,5 +38,5 @@ expect(err).to.not.exist();

it('composes server with server.cache as a string', function (done) {
it('composes a server with server.cache as a string', (done) => {
var manifest = {
const manifest = {
server: {

@@ -46,3 +47,3 @@ cache: '../node_modules/catbox-memory'

Glue.compose(manifest, function (err, server) {
Glue.compose(manifest, (err, server) => {

@@ -54,5 +55,5 @@ expect(err).to.not.exist();

it('composes server with server.cache as an array', function (done) {
it('composes a server with server.cache as an array', (done) => {
var manifest = {
const manifest = {
server: {

@@ -63,3 +64,3 @@ cache: ['../node_modules/catbox-memory']

Glue.compose(manifest, function (err, server) {
Glue.compose(manifest, (err, server) => {

@@ -71,5 +72,5 @@ expect(err).to.not.exist();

it('composes server with server.cache.engine as a string', function (done) {
it('composes a server with server.cache.engine as a string', (done) => {
var manifest = {
const manifest = {
server: {

@@ -82,3 +83,3 @@ cache: {

Glue.compose(manifest, function (err, server) {
Glue.compose(manifest, (err, server) => {

@@ -90,5 +91,5 @@ expect(err).to.not.exist();

it('composes server with server.cache.engine as a function', function (done) {
it('composes a server with server.cache.engine as a function', (done) => {
var manifest = {
const manifest = {
server: {

@@ -101,3 +102,3 @@ cache: [{

Glue.compose(manifest, function (err, server) {
Glue.compose(manifest, (err, server) => {

@@ -109,5 +110,5 @@ expect(err).to.not.exist();

it('composes server with server.cache.engine resolved using options.relativeTo', function (done) {
it('composes a server with server.cache.engine resolved using options.relativeTo', (done) => {
var manifest = {
const manifest = {
server: {

@@ -118,3 +119,3 @@ cache: '../../node_modules/catbox-memory'

Glue.compose(manifest, { relativeTo: __dirname + '/plugins' }, function (err, server) {
Glue.compose(manifest, { relativeTo: __dirname + '/plugins' }, (err, server) => {

@@ -126,182 +127,217 @@ expect(err).to.not.exist();

it('composes server with connections array having multiple entries', function (done) {
describe('composes a server\'s connections', () => {
var manifest = {
connections: [
{ labels: 'a' },
{ labels: 'b' }
]
};
it('has no entries', (done) => {
Glue.compose(manifest, function (err, server) {
const manifest = {
connections: []
};
expect(err).to.not.exist();
expect(server.connections).length(2);
done();
Glue.compose(manifest, (err, server) => {
expect(err).to.not.exist();
expect(server.connections).length(1);
done();
});
});
});
it('composes server with plugins having a plugin with null options', function (done) {
it('has a single entry', (done) => {
var manifest = {
plugins: {
'../test/plugins/helloworld.js': null
}
};
const manifest = {
connections: [
{ labels: 'a' }
]
};
Glue.compose(manifest, function (err, server) {
Glue.compose(manifest, (err, server) => {
expect(err).to.not.exist();
expect(server.plugins.helloworld).to.exist();
expect(server.plugins.helloworld.hello).to.equal('world');
done();
expect(err).to.not.exist();
expect(server.connections).length(1);
done();
});
});
});
it('composes server with plugins having a plugin registered with options', function (done) {
it('has multiple entries', (done) => {
var manifest = {
plugins: {
'../test/plugins/helloworld.js': { who: 'earth' }
}
};
const manifest = {
connections: [
{ labels: 'a' },
{ labels: 'b' }
]
};
Glue.compose(manifest, function (err, server) {
Glue.compose(manifest, (err, server) => {
expect(err).to.not.exist();
expect(server.plugins.helloworld).to.exist();
expect(server.plugins.helloworld.hello).to.equal('earth');
done();
expect(err).to.not.exist();
expect(server.connections).length(2);
done();
});
});
});
it('composes server with plugins having a plugin with null options and null register options', function (done) {
describe('composes a server\'s registrations', () => {
var manifest = {
plugins: {
'../test/plugins/helloworld.js': [{}]
}
};
it('has no registrations', (done) => {
Glue.compose(manifest, function (err, server) {
const manifest = {
registrations: []
};
expect(err).to.not.exist();
expect(server.plugins.helloworld).to.exist();
expect(server.plugins.helloworld.hello).to.equal('world');
done();
Glue.compose(manifest, (err, server) => {
expect(err).to.not.exist();
expect(server.plugins).length(0);
done();
});
});
});
it('composes server with plugins having a plugin registered with register options', function (done) {
it('has a registration with no configuration', (done) => {
var manifest = {
plugins: {
'../test/plugins/route.js': [{
routes: { prefix: '/test/' }
}]
}
};
const manifest = {
registrations: [
{
plugin: '../test/plugins/helloworld.js'
}
]
};
Glue.compose(manifest, function (err, server) {
Glue.compose(manifest, (err, server) => {
expect(err).to.not.exist();
server.inject('/test/plugin', function (response) {
expect(response.statusCode).to.equal(200);
expect(err).to.not.exist();
expect(server.plugins.helloworld).to.exist();
expect(server.plugins.helloworld.hello).to.equal('world');
done();
});
});
});
it('composes server with plugins having a plugin loaded multiple times', function (done) {
it('has a registration with no plugin options and no register options', (done) => {
var manifest = {
connections: [
{ labels: 'a' },
{ labels: 'b' }
],
plugins: {
'../test/plugins/route.js': [
const manifest = {
registrations: [
{
select: 'a',
routes: { prefix: '/a/' }
},
{
select: 'b',
routes: { prefix: '/b/' }
plugin: {
register: '../test/plugins/helloworld.js'
}
}
]
}
};
};
Glue.compose(manifest, function (err, server) {
Glue.compose(manifest, (err, server) => {
expect(err).to.not.exist();
server.select('a').inject('/a/plugin', function (responseA) {
expect(err).to.not.exist();
expect(server.plugins.helloworld).to.exist();
expect(server.plugins.helloworld.hello).to.equal('world');
done();
});
});
expect(responseA.statusCode).to.equal(200);
server.select('b').inject('/b/plugin', function (responseB) {
it('has a registration with plugin options and no register options', (done) => {
expect(responseB.statusCode).to.equal(200);
done();
});
const manifest = {
registrations: [
{
plugin: {
register: '../test/plugins/helloworld.js',
options: { who: 'earth' }
}
}
]
};
Glue.compose(manifest, (err, server) => {
expect(err).to.not.exist();
expect(server.plugins.helloworld).to.exist();
expect(server.plugins.helloworld.hello).to.equal('earth');
done();
});
});
});
it('composes server with plugins resolved using options.relativeTo', function (done) {
it('has a registration with register options and no plugin options', (done) => {
var manifest = {
plugins: {
'./helloworld.js': null
}
};
const manifest = {
registrations: [
{
plugin: '../test/plugins/route.js',
options: {
routes: { prefix: '/test/' }
}
}
]
};
Glue.compose(manifest, { relativeTo: __dirname + '/plugins' }, function (err, server) {
Glue.compose(manifest, (err, server) => {
expect(err).to.not.exist();
expect(server.plugins.helloworld.hello).to.equal('world');
done();
expect(err).to.not.exist();
server.inject('/test/plugin', (response) => {
expect(response.statusCode).to.equal(200);
done();
});
});
});
});
describe('Array of plugins', function () {
it('has registrations having the same plugin loaded multiple times', (done) => {
it('composes server with plugins being an array of plugin objects', function (done) {
var manifest = {
plugins: [
{ '../test/plugins/helloworld.js': null }
const manifest = {
connections: [
{ labels: 'a' },
{ labels: 'b' }
],
registrations: [
{
plugin: '../test/plugins/route.js',
options: {
select: 'a',
routes: { prefix: '/a/' }
}
},
{
plugin: '../test/plugins/route.js',
options: {
select: 'b',
routes: { prefix: '/b/' }
}
}
]
};
Glue.compose(manifest, function (err, server) {
Glue.compose(manifest, (err, server) => {
expect(err).to.not.exist();
expect(server.plugins.helloworld).to.exist();
expect(server.plugins.helloworld.hello).to.equal('world');
done();
server.select('a').inject('/a/plugin', (responseA) => {
expect(responseA.statusCode).to.equal(200);
server.select('b').inject('/b/plugin', (responseB) => {
expect(responseB.statusCode).to.equal(200);
done();
});
});
});
});
it('Only accepts plugin objects with 1 key', { timeout: 30000 }, function (done) {
it('has a registration with the plugin resolved using options.relativeTo', (done) => {
var manifest = {
plugins: [
{ 'test': null, 'fail': null }
const manifest = {
registrations: [
{
plugin: './helloworld.js'
}
]
};
expect(function () {
Glue.compose(manifest, { relativeTo: __dirname + '/plugins' }, (err, server) => {
Glue.compose(manifest, function () {});
}).to.throw('Invalid plugin config');
done();
expect(err).to.not.exist();
expect(server.plugins.helloworld.hello).to.equal('world');
done();
});
});
});
it('composes server with preConnections handler', function (done) {
it('composes a server with a preConnections handler', (done) => {
var manifest = {};
var options = {
const manifest = {};
const options = {
preConnections: function (server, callback) {

@@ -313,3 +349,3 @@

Glue.compose(manifest, options, function (err, server) {
Glue.compose(manifest, options, (err, server) => {

@@ -321,7 +357,7 @@ expect(err).to.not.exist();

it('composes server with prePlugins handler', function (done) {
it('composes a server with a preRegister handler', (done) => {
var manifest = {};
var options = {
prePlugins: function (server, callback) {
const manifest = {};
const options = {
preRegister: function (server, callback) {

@@ -332,3 +368,3 @@ callback();

Glue.compose(manifest, options, function (err, server) {
Glue.compose(manifest, options, (err, server) => {

@@ -340,7 +376,7 @@ expect(err).to.not.exist();

it('errors on failed pre handler', function (done) {
it('errors on failed pre handler', (done) => {
var manifest = {};
var options = {
prePlugins: function (server, callback) {
const manifest = {};
const options = {
preRegister: function (server, callback) {

@@ -351,3 +387,3 @@ callback({ error: 'failed' });

Glue.compose(manifest, options, function (err, server) {
Glue.compose(manifest, options, (err, server) => {

@@ -359,5 +395,5 @@ expect(err).to.exist();

it('throws on bogus options.realativeTo path (server.cache)', function (done) {
it('throws on bogus options.realativeTo path (server.cache)', (done) => {
var manifest = {
const manifest = {
server: {

@@ -368,5 +404,5 @@ cache: './catbox-memory'

expect(function () {
expect(() => {
Glue.compose(manifest, { relativeTo: __dirname + '/badpath' }, function () { });
Glue.compose(manifest, { relativeTo: __dirname + '/badpath' }, () => { });
}).to.throw(/Cannot find module/);

@@ -376,13 +412,15 @@ done();

it('throws on bogus options.realativeTo path (plugins)', function (done) {
it('throws on bogus options.realativeTo path (plugins)', (done) => {
var manifest = {
plugins: {
'./helloworld.js': null
}
const manifest = {
registrations: [
{
plugin: './helloworld.js'
}
]
};
expect(function () {
expect(() => {
Glue.compose(manifest, { relativeTo: __dirname + '/badpath' }, function () { });
Glue.compose(manifest, { relativeTo: __dirname + '/badpath' }, () => { });
}).to.throw(/Cannot find module/);

@@ -392,9 +430,9 @@ done();

it('throws on options not an object', function (done) {
it('throws on options not an object', (done) => {
var manifest = {};
const manifest = {};
expect(function () {
expect(() => {
Glue.compose(manifest, 'hello', function () { });
Glue.compose(manifest, 'hello', () => { });
}).to.throw(/Invalid options/);

@@ -404,7 +442,7 @@ done();

it('throws on callback not a function', function (done) {
it('throws on callback not a function', (done) => {
var manifest = {};
const manifest = {};
expect(function () {
expect(() => {

@@ -416,9 +454,9 @@ Glue.compose(manifest, 'hello');

it('throws on invalid manifest (not an object)', function (done) {
it('throws on invalid manifest (not an object)', (done) => {
var manifest = 'hello';
const manifest = 'hello';
expect(function () {
expect(() => {
Glue.compose(manifest, function () { });
Glue.compose(manifest, () => { });
}).to.throw(/Invalid manifest/);

@@ -428,11 +466,11 @@ done();

it('throws on invalid manifest (server not an object)', function (done) {
it('throws on invalid manifest (server not an object)', (done) => {
var manifest = {
const manifest = {
server: 'hello'
};
expect(function () {
expect(() => {
Glue.compose(manifest, function () { });
Glue.compose(manifest, () => { });
}).to.throw(/Invalid manifest/);

@@ -442,11 +480,11 @@ done();

it('throws on invalid manifest (connections not an array)', function (done) {
it('throws on invalid manifest (connections not an array)', (done) => {
var manifest = {
const manifest = {
connections: 'hello'
};
expect(function () {
expect(() => {
Glue.compose(manifest, function () { });
Glue.compose(manifest, () => { });
}).to.throw(/Invalid manifest/);

@@ -456,57 +494,14 @@ done();

it('throws on invalid manifest (connections must have at least one entry)', function (done) {
it('throws on invalid manifest (registrations not an array)', (done) => {
var manifest = {
connections: []
const manifest = {
registrations: 'hello'
};
expect(function () {
expect(() => {
Glue.compose(manifest, function () { });
Glue.compose(manifest, () => { });
}).to.throw(/Invalid manifest/);
done();
});
it('throws on invalid manifest (plugins not an object)', function (done) {
var manifest = {
plugins: 'hello'
};
expect(function () {
Glue.compose(manifest, function () { });
}).to.throw(/Invalid manifest/);
done();
});
it('throws on invalid plugin configuration (empty instances)', function (done) {
var manifest = {
plugins: {
'../test/plugins/helloworld.js': []
}
};
expect(function () {
Glue.compose(manifest, function () { });
}).to.throw(/Invalid plugin configuration/);
done();
});
it('throws on invalid plugin configuration (bogus instance)', function (done) {
var manifest = {
plugins: {
'../test/plugins/helloworld.js': ['bogus']
}
};
expect(function () {
Glue.compose(manifest, function () { });
}).to.throw(/Invalid plugin configuration/);
done();
});
});

@@ -0,1 +1,3 @@

'use strict';
exports.register = function (server, options, next) {

@@ -2,0 +4,0 @@

@@ -0,1 +1,3 @@

'use strict';
exports.register = function (server, options, next) {

@@ -2,0 +4,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc