Skip to content

Instantly share code, notes, and snippets.

@Marak
Created July 25, 2015 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marak/52090dad244f7e06065e to your computer and use it in GitHub Desktop.
Save Marak/52090dad244f7e06065e to your computer and use it in GitHub Desktop.
hook.io example microservice for setting schema on hook parameter input
module['exports'] = function inputSchema (hook, callback) {
// Responds back with incoming Hook parameters
hook.res.end(JSON.stringify(hook.params, true, 2));
};
// Specify an optional schema object
// This enables validation and defaults for Hook input
// For complete documentation on available schema types,
// see: http://github.com/mschema/mschema
module['exports'].schema = {
"name": {
"type": "string",
"default": "Bob",
"required": false
},
"age": {
"type": "number",
"default": 40
},
"status": {
"type": "string",
"default": "active",
"enum": ["active", "disabled"]
},
"isAlive": {
"type": "boolean",
"default": true
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment