 #
 # Configuration:
 #   HUBOT_JIRA_DOMAIN
+#   HUBOT_JIRA_PROTOCOL (optional, format: "http|https"; default is "https")
+#   HUBOT_JIRA_PORT (optional; default is 80)
 #   HUBOT_JIRA_IGNORECASE (optional; default is "true")
 #   HUBOT_JIRA_USERNAME (optional)
 #   HUBOT_JIRA_PASSWORD (optional)

module.exports = (robot) ->
  cache = []
  jiraDomain = process.env.HUBOT_JIRA_DOMAIN
  jiraUrl = "https://" + jiraDomain
  http = require 'https'

  jiraUsername = process.env.HUBOT_JIRA_USERNAME
  jiraPassword = process.env.HUBOT_JIRA_PASSWORD

  if jiraIgnoreUsers == undefined
    jiraIgnoreUsers = "jira|github"

  request = http.get {host: jiraDomain, port: jiraPort, auth: auth, path: "/rest/api/2/project"}, (res) ->
    data = ''
    res.on 'data', (chunk) ->
      data += chunk.toString()
