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.1.1 to 2.2.0

39

lib/index.js

@@ -29,41 +29,2 @@ // Load modules

/*
// Example manifest
var manifest = {
server: {
cache: 'redis',
app: {
'app-specific': 'value'
}
},
connections: [
{
port: 8001,
labels: ['api', 'nasty']
},
{
host: 'localhost',
port: '$env.PORT',
labels: ['api', 'nice']
}
],
plugins: {
furball: {
version: false,
plugins: '/'
},
other: [
{
select: ['b'],
options: {
version: false,
plugins: '/'
}
}
]
}
};
*/
exports.compose = function (manifest /*, [options], callback */) {

@@ -70,0 +31,0 @@

6

package.json
{
"name": "glue",
"description": "Server composer for hapi.js",
"version": "2.1.1",
"version": "2.2.0",
"repository": {

@@ -22,6 +22,6 @@ "type": "git",

"boom": "2.x.x",
"hapi": "8.x.x",
"hapi": "8.x.x || 9.x.x",
"hoek": "2.x.x",
"items": "1.x.x",
"joi": "5.x.x"
"joi": "5.x.x || 6.x.x"
},

@@ -28,0 +28,0 @@ "devDependencies": {

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

#glue
# glue
Server composer for hapi.js.
[![Build Status](https://secure.travis-ci.org/hapijs/glue.png)](http://travis-ci.org/hapijs/glue)
[![Build Status](https://travis-ci.org/hapijs/glue.svg?branch=master)](https://travis-ci.org/hapijs/glue)

@@ -17,5 +17,5 @@ Lead Maintainer - [Chris Rempel](https://github.com/csrl)

* '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(plugins, [options], callback)`](http://hapijs.com/api#serverregisterplugins-options-callback). Note that when using an object, the order of registration is not garanteed, while with the array it is. Still when you want absolutely garantee the order of plugin loading use the hapi built in way, [`server.dependecy(dependencies, [after])`](http://hapijs.com/api#serverdependencydependencies-after). Each key is the `name` of the plugin to load and register and the value is one of:
* '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 the plugin's `attributes.multiple` is `true`. Each object can have:
+ 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

@@ -35,6 +35,8 @@ * `options` - an object to use as the plugin options which get passed to the plugin's registration function when called.

### Notes
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.
## Usage
You create a manifest and then you can use the manifest for creating the new server:
```javascript

@@ -44,17 +46,41 @@ var Glue = require('glue');

var manifest = {
server: {
debug: {
request: ['error']
}
},
connections: [{
port: 8080
}],
plugins: {
'./routes/index': {}
}
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
}
}
]}
]
};
var options = {
relativeTo: __dirname
relativeTo: __dirname
};

@@ -69,5 +95,51 @@

console.log('woot');
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!');
});
});
});
});
```
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