Skip to content

Instantly share code, notes, and snippets.

@stongo
Last active December 24, 2015 02:29
Show Gist options
  • Save stongo/6731304 to your computer and use it in GitHub Desktop.
Save stongo/6731304 to your computer and use it in GitHub Desktop.
Implementation example of mudskipper plugin for HAPI framework
module.exports = function(Hapi) {
return {
/**
* @operation: GET
* @path: '/appointment'
*/
index: {
handler: function (request) {
}
}
}
}
module.exports = function(Hapi) {
return {
/**
* @operation: GET
* @path: '/appointment/:appointment_id/booking'
*/
index: {
handler: function (request) {
}
}
}
}
module.exports = function(Hapi) {
// REST Resources
var resources = {};
// Struggling with the proper way to set children
resources.appointment = require('./appointment.js')(Hapi);
resources.appointment.children = [ { booking: require('./booking.js')(Hapi) } ];
return resources;
}
// Create rest service
module.exports = function(Hapi) {
// RESTful resources
var resources = require('./resources.js')(Hapi);
// Create rest service
var rest = new Hapi.Pack();
var config = {
labels: "rest",
};
rest.server(3000, config);
rest.require('mudskipper', resources, function (err) {
if (err) console.error('failed to load resourceful routes:', err);
});
rest.start(function(err) {
if (err) return console.error('REST service start error: ' + err);
console.log('REST service started on port 3000');
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment