Skip to content

Instantly share code, notes, and snippets.

@mose
Created October 26, 2016 09:44
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 mose/2f870a224da4ebc648f2fc01e1c21494 to your computer and use it in GitHub Desktop.
Save mose/2f870a224da4ebc648f2fc01e1c21494 to your computer and use it in GitHub Desktop.
module.exports = (robot) ->
robot.router.post "/#{robot.name}/capture/:feed", (req, res) ->
filepath = path.join process.env.FILE_BRAIN_PATH, "#{req.params.feed}"
payload = req.body
fs.appendFileSync filepath, "\n---------------------\n#{moment().utc().format()}\n\n"
fs.appendFileSync filepath, JSON.stringify(req.body, null, 2), 'utf-8'
res.setHeader 'content-type', 'text/plain'
res.status(200).end ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment