Last active
December 24, 2015 02:29
-
-
Save stongo/6731304 to your computer and use it in GitHub Desktop.
Implementation example of mudskipper plugin for HAPI framework
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
module.exports = function(Hapi) { | |
return { | |
/** | |
* @operation: GET | |
* @path: '/appointment' | |
*/ | |
index: { | |
handler: function (request) { | |
} | |
} | |
} | |
} |
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
module.exports = function(Hapi) { | |
return { | |
/** | |
* @operation: GET | |
* @path: '/appointment/:appointment_id/booking' | |
*/ | |
index: { | |
handler: function (request) { | |
} | |
} | |
} | |
} |
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
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; | |
} |
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
// 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