Skip to content

Instantly share code, notes, and snippets.

@jakepruitt
Created January 15, 2015 05:42
Show Gist options
  • Select an option

  • Save jakepruitt/e353fbc1869d4eb3150b to your computer and use it in GitHub Desktop.

Select an option

Save jakepruitt/e353fbc1869d4eb3150b to your computer and use it in GitHub Desktop.
seneca-hapi API example
var Hapi = require('hapi');
var seneca = require('seneca')();
var server = new Hapi.Server();
seneca.add({role: 'test', cmd: 'test'}, function(args, done) {
console.log('Recieved a request');
done(null, {worked: true});
});
seneca.use('./seneca-hapi.js');
seneca.act('role: hapi, cmd: register', {
path: '/api/1.0',
pin: { role: 'test', cmd: '*' }
});
server.register(seneca.export('hapi'), function(err) {
if (err) {
console.error(err);
} else {
server.start();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment