Created
February 20, 2016 22:23
-
-
Save tdantas/d8ceb1869459a0b44432 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); }); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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