Created
July 30, 2015 20:04
-
-
Save pon/df5a1f22c4409db1c50c to your computer and use it in GitHub Desktop.
hapi.js
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 Bluebird = require('bluebird'); | |
var Hapi = require('hapi'); | |
var Server = new Hapi.Server(); | |
Server.connection({ port: 3000 }); | |
Server.method('pAdd', function (a, b) { | |
return Bluebird.resolve(a + b); | |
}); | |
Server.route({ | |
method: 'GET', | |
path: '/', | |
config: { | |
pre: [ | |
{ method: 'pAdd(1, 2)', assign: 'val' } // Never resolves | |
], | |
handler: function (request, reply) { | |
reply(Server.methods.pAdd(1, 2)); // Resolves and replies | |
} | |
} | |
}); | |
Server.start(); | |
console.log('Server started on', Server.info.uri); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment