refactor out https to github

This commit is contained in:
Radek Stepan 2012-05-22 17:35:53 +01:00
parent f095be9b1a
commit 516a1eac24

View File

@ -8,6 +8,15 @@ options =
path: "/repos/intermine/InterMine/issues"
method: "GET"
getIssues = (callback) ->
https.request(options, (response) ->
if response.statusCode is 200
json = ""
response.on "data", (chunk) -> json += chunk
response.on "end", -> callback JSON.parse json
).end()
app = express.createServer()
app.configure ->
@ -34,16 +43,10 @@ app.configure 'production', ->
# Routes
app.get '/issues', (req, res) ->
https.request(options, (response) ->
if response.statusCode is 200
json = ""
response.on "data", (chunk) -> json += chunk
response.on "end", ->
getIssues (issues) ->
res.render 'issues',
'issues': JSON.parse json
'issues': issues
, (html) -> res.send html, 'Content-Type': 'text/html', 200
).end()
app.listen 3000
console.log "Express server listening to port 3000"