Last active
April 25, 2017 02:44
-
-
Save catarak/7d7b8f336b88a72d32e2a9fcbe235f83 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 api(options) { | |
var validActions = { add:'add' } | |
this.add('role:api,path:todo', function (msg, respond) { | |
var action = msg.args.params.action; | |
var todoText = msg.args.body.text; | |
this.act('role:todo', { | |
cmd: validActions[action], // do this to prevent injection attacks | |
text: text, | |
}, respond); | |
}); | |
this.add('init:api', function (msg, respond) { | |
this.act('role:web',{ routes: { | |
prefix: '/api', | |
pin: 'role:api,path:*', | |
map: { | |
todo: { POST: true, suffix:'/:action' } | |
} | |
}}, respond); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment