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 3.0.0 to 3.1.0

43

API.md

@@ -6,3 +6,3 @@

### `compose(manifest, [options], callback)`
### `compose(manifest, [options], [callback])`

@@ -29,2 +29,4 @@ Composes a hapi server object where:

If no `callback` is provided, a `Promise` object is returned where the value passed to the Promise resolve handler is the `server` object and the value passed to the Promise reject handler is the error response if a failure occurred.
### Notes

@@ -37,2 +39,4 @@

```javascript
'use strict';
const Glue = require('glue');

@@ -105,16 +109,15 @@

```javascript
const server = Hapi.Server({cache: [{engine: require('redis')}]});
server.connection({
port: 8000,
labels: ['web']
});
server.connection({
port: 8001,
labels: ['admin']
});
let plugin, pluginPath, pluginOptions, registerOptions;
'use strict';
const server = Hapi.Server({ cache: [{ engine: require('redis') }] });
server.connection({ port: 8000, labels: ['web'] });
server.connection({ port: 8001, labels: ['admin'] });
let plugin;
let pluginPath;
let pluginOptions;
let registerOptions;
pluginPath = Path.join(__dirname, './assets');
pluginOptions = {uglify: true};
plugin = {register: require(pluginPath), options: pluginOptions};
registerOptions = {};
pluginOptions = { uglify: true };
plugin = { register: require(pluginPath), options: pluginOptions };
registerOptions = { };
server.register(plugin, registerOptions, (err) => {

@@ -126,5 +129,5 @@

pluginPath = Path.join(__dirname, './ui-user');
pluginOptions = {};
plugin = {register: require(pluginPath), options: pluginOptions};
registerOptions = {select: ['web']};
pluginOptions = { };
plugin = { register: require(pluginPath), options: pluginOptions };
registerOptions = { select: ['web'] };
server.register(plugin, registerOptions, (err) => {

@@ -136,5 +139,5 @@

pluginPath = Path.join(__dirname, './ui-admin');
pluginOptions = {sessiontime: 500};
plugin = {register: require(pluginPath), options: pluginOptions};
registerOptions = {select: ['admin'], routes: {prefix: '/admin'}};
pluginOptions = { sessiontime: 500 };
plugin = { register: require(pluginPath), options: pluginOptions };
registerOptions = { select: ['admin'], routes: { prefix: '/admin' } };
server.register(plugin, registerOptions, (err) => {

@@ -141,0 +144,0 @@

@@ -36,11 +36,28 @@ 'use strict';

exports.compose = function (manifest /*, [options], callback */) {
exports.compose = function (manifest /*, [options], [callback] */) {
const options = arguments.length === 2 ? {} : arguments[1];
const callback = arguments.length === 2 ? arguments[1] : arguments[2];
Hoek.assert(arguments.length <= 3, 'Invalid number of arguments');
Hoek.assert(typeof callback === 'function', 'Invalid callback');
const options = arguments.length === 1 || typeof arguments[1] === 'function' ? {} : arguments[1];
const callback = typeof arguments[arguments.length - 1] === 'function' ? arguments[arguments.length - 1] : null;
Joi.assert(options, internals.schema.options, 'Invalid options');
Joi.assert(manifest, internals.schema.manifest, 'Invalid manifest');
// Return Promise if no callback provided
if (!callback) {
return new Promise((resolve, reject) => {
exports.compose(manifest, options, (err, server) => {
if (err) {
return reject(err);
}
return resolve(server);
});
});
}
// Create server

@@ -47,0 +64,0 @@

{
"name": "glue",
"description": "Server composer for hapi.js",
"version": "3.0.0",
"version": "3.1.0",
"repository": {

@@ -21,4 +21,3 @@ "type": "git",

"dependencies": {
"boom": "3.x.x",
"hapi": "11.x.x",
"hapi": "11.x.x || 12.x.x",
"hoek": "3.x.x",

@@ -31,3 +30,3 @@ "items": "2.x.x",

"code": "2.x.x",
"lab": "7.x.x"
"lab": "8.x.x"
},

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

@@ -27,2 +27,2 @@ ## glue

Glue currently supports hapi **11**.
Glue currently supports hapi **11** and **12**.

@@ -36,2 +36,60 @@ 'use strict';

it('returns a promise if no options and no callback is provided', (done) => {
const manifest = {};
Glue.compose(manifest).then((server) => {
expect(server.connections).length(1);
done();
});
});
it('returns a promise if no callback is provided', (done) => {
const manifest = {};
const options = {};
Glue.compose(manifest, options).then((server) => {
expect(server.connections).length(1);
done();
});
});
it('rejects a promise if an error is thrown', (done) => {
const manifest = {
registrations: [
{
plugin: './invalid-plugin'
}
]
};
Glue.compose(manifest).catch((err) => {
expect(err).to.exist();
expect(err.code).to.equal('MODULE_NOT_FOUND');
done();
});
});
it('rejects a promise if an error is returned', (done) => {
const manifest = {};
const options = {
preRegister: function (server, callback) {
callback({ error: 'failed' });
}
};
Glue.compose(manifest, options).then(null, (err) => {
expect(err).to.exist();
done();
});
});
it('composes a server with server.cache as a string', (done) => {

@@ -421,13 +479,2 @@

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

@@ -434,0 +481,0 @@

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