Skip to content

Instantly share code, notes, and snippets.

@myszek123
Forked from Marak/datastoreExample.js
Last active September 16, 2015 14:58
Show Gist options
  • Save myszek123/6f181819073eb59566fb to your computer and use it in GitHub Desktop.
Save myszek123/6f181819073eb59566fb to your computer and use it in GitHub Desktop.
hook.io example microservice for using hook.io's cloud datastore API
module['exports'] = function datastoreExample (hook) {
var res = hook.res,
req = hook.req,
store = hook.datastore;
if (hook.params.ddd) {
store.set('mykey', { foo: hook.params.ddd }, function(err, result){
if (err) { return res.end(err.message); }
return res.end("ok");
});
} else {
store.get('mykey', function(err, result){
if (err) { return res.end(err.message); }
return res.end(JSON.stringify(result, true, 2));
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment