Skip to content

firstandthird/hapi-method-routes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#hapi-method-routes is a plugin that exposes server methods as routes

Example:

server.method('add', (a, b, done) => done(null, a.toString() + b.toString()), {});
server.inject({
  url: '/methods',
  method: 'POST',
  payload: {
    method: 'add(20, 25)'
  }
}, response => {
  console.log(response.result.successful);
  console.log(response.result.result);
});

will print 'true' and '2025'. See tests for more examples.