Created
May 13, 2016 10:16
-
-
Save aegyed91/4cec4cc16048cd3458b17cc3cce5b84a to your computer and use it in GitHub Desktop.
hapi server method promise bug reproduction
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'); | |
const server = new Hapi.Server({ | |
cache: [ | |
{ | |
name: 'redisCache', | |
engine: require('catbox-redis'), | |
host: '127.0.0.1', | |
partition: 'cache' | |
} | |
] | |
}); | |
server.connection({ | |
port: 8000 | |
}); | |
server.method('test', function () { | |
return Promise.resolve('works'); | |
}, { | |
// if you remove the cache options it works as expected | |
cache: { | |
cache: 'redisCache', | |
expiresIn: 30 * 1000, | |
generateTimeout: 100 | |
} | |
}); | |
server.route({ | |
path: '/test', | |
method: 'GET', | |
handler: function (request, reply) { | |
server.methods | |
.test() | |
.then(function (msg) { | |
reply(msg); | |
}) | |
.catch(function (err) { | |
reply(err); | |
}); | |
} | |
}); | |
server | |
.start() | |
.then(function() { | |
console.log('check localhost:8000/test'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment