Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Server composer for hapi.js.
Lead Maintainer - Chris Rempel
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, but can be integrated directly into any Hapi application loader.
compose(manifest, [options], callback)
manifest
- an object having:
new Server([options])
server.connection([options])
server.register(plugin, [options], callback)
. Each object key is the name
of the plugin to load and register and the value is one of:
attributes.multiple
as true
. Each object can have:
server.register
optionsoptions
- an object to use as the plugin options which get passed to the plugin's registration function when called.options
- an object having
require
. Used in server.cache
and plugins[name]
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 gluefunction (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 gluecallback
- 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.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])
for more information.
var Glue = require('glue');
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
}
}
]}
]
};
var options = {
relativeTo: __dirname
};
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.
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!');
});
});
});
});
FAQs
Server composer for hapi.js
The npm package glue receives a total of 181 weekly downloads. As such, glue popularity was classified as not popular.
We found that glue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.