UNPKG

833 Btext/coffeescriptView Raw
1# Description:
2# kinda proxies the Conduit API with proper REST syntax calls
3#
4# Configuration:
5# PHABRICATOR_URL
6# PHABRICATOR_API_KEY
7#
8# Urls:
9# POST /hubot/phabs/api/:project/task
10#
11# Author:
12# mose
13#
14# Notes:
15# It's advised to protect this endpoint using
16# hubot-restrict-ip https://github.com/Gandi/hubot-restrict-ip
17# or a nginx/apache proxy
18#
19# Examples:
20# curl -XPOST -H "Content-Type: application/json" -d @test/samples/create_task.json \
21# http://localhost:8080/hubot/phabs/api/test-project/task
22
23module.exports = (robot) ->
24
25 robot.router.post "/#{robot.name}/phabs/api/:project/task", (req, res) ->
26 if req.body.title?
27 payload = req.body
28 payload.project = req.params.project
29 robot.emit 'phab.createTask', payload
30 res.status(200).end()
31 else
32 res.status(422).end()