Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//path: plugins/admin.js
const plugin = module.exports;
plugin.register = register;
plugin.register.attributes = {
name: 'admin plugin',
version: '0.0.1-alpha-beta-gama'
};
function register(server, options, next) {
server.route({
method: 'GET',
path: '/',
handler: (req, reply) => { reply('admin handler'); }
});
next();
}
const Glue = require('glue');
const path = require('path');
const admin = {
plugin: './admin',
options: { select: ['admin'] }
};
const users = {
plugin: './users',
options: { select: ['users', 'admin'] }
};
const manifest = {
connections: [{ port: 3000, labels: ['users'] }, { port: 3001, labels: ['admin'] } ],
registrations: [ admin, users ]
};
const relativeTo = path.resolve(__dirname, 'plugins');
Glue.compose(manifest, { relativeTo }, (err, server) => {
if (err)
throw err;
server.start(() => { console.log('server running'); });
});
// path: plugins/users.js
const plugin = module.exports;
plugin.register = register;
plugin.register.attributes = {
name: 'users plugin',
version: '0.0.1-alpha-beta-gama'
};
function register(server, options, next) {
server.route({
method: 'GET',
path: '/users',
handler: (req, reply) => { reply('users handler'); }
});
next();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment