Created
May 6, 2014 12:18
-
-
Save PaulMougel/2f33c5642b46034f1298 to your computer and use it in GitHub Desktop.
Hapi hanging with plugin dependency
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
var Hapi = require('hapi'); | |
var plugins = { | |
yar: { | |
cookieOptions: { | |
password: "mypassword", | |
isSecure: false | |
} | |
}, | |
travelogue: { | |
hostname: "localhost", | |
port: 8082, | |
urls: { | |
failureRedirect: "/auth/login.html", | |
successRedirect: "/auth/login" | |
} | |
}, | |
'./test-plugin': {} | |
}; | |
var server = new Hapi.Server('localhost', 8082); | |
server.pack.require(plugins, function(err) { | |
if (err) throw err; | |
server.start(); | |
}); |
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
{ | |
"name": "hapiTest", | |
"version": "0.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "BSD-2-Clause", | |
"dependencies": { | |
"yar": "~2.1.0", | |
"travelogue": "~2.0.0", | |
"hapi": "~3.1.0", | |
"passport": "~0.2.0", | |
"passport-persona": "~0.1.7" | |
} | |
} |
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
// The file is stored in test-plugin/index.js | |
// for some reason gists don't allow / in file names... | |
exports.register = function (plugin, options, next) { | |
// Crashes at startup: | |
// undefined.someProperty; | |
plugin.dependency('travelogue', after); | |
next(); | |
}; | |
function after (plugin, next) { | |
// Hangs but doesn't crash: | |
// undefined.someProperty; | |
plugin.route({ | |
path: '/', | |
method: 'GET', | |
handler: function (request, reply) { | |
reply({ok: true}) | |
} | |
}) | |
next(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment