Last active
January 3, 2016 15:39
-
-
Save nlf/8484427 to your computer and use it in GitHub Desktop.
mudskipper in plugins
This file contains 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
var internals = { | |
resources: { | |
users: { | |
index: function (request, reply) { | |
reply('ok'); | |
} | |
} | |
} | |
}; | |
exports.register = function (plugin, options, next) { | |
plugin.dependency('mudskipper'); | |
plugin.plugins.mudskipper.route(internals, next); | |
}; | |
exports.name = 'plugin1'; | |
exports.version = '0.0.1'; |
This file contains 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
var internals = { | |
resources: { | |
articles: { | |
index: function (request, reply) { | |
reply('ok'); | |
} | |
} | |
} | |
}; | |
exports.register = function (plugin, options, next) { | |
plugin.dependency('mudskipper'); | |
plugin.plugins.mudskipper.route(internals, next); | |
}; | |
exports.name = 'plugin2'; | |
exports.version = '0.0.1'; |
This file contains 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
var Hapi = require('hapi'); | |
var server = new Hapi.Server('127.0.0.1', 8000); | |
var plugin1 = require('./plugin1'); | |
var plugin2 = require('./plugin2'); | |
server.pack.require(['mudskipper'], function (err) { | |
server.pack.register(plugin1, null, function () { | |
server.pack.register(plugin2, null, function () { | |
server.start(function () { | |
console.log('server running at ' + server.info.uri); | |
}) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment