Skip to content

Instantly share code, notes, and snippets.

@tdantas
Created February 20, 2016 22:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tdantas/d8ceb1869459a0b44432 to your computer and use it in GitHub Desktop.
Save tdantas/d8ceb1869459a0b44432 to your computer and use it in GitHub Desktop.
//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