mirror of
https://github.com/status-im/burnchart.git
synced 2025-01-31 12:55:20 +00:00
49 lines
1.2 KiB
CoffeeScript
49 lines
1.2 KiB
CoffeeScript
express = require 'express'
|
|
eco = require 'eco'
|
|
https = require 'https'
|
|
fs = require "fs"
|
|
|
|
options =
|
|
host: "api.github.com"
|
|
path: "/repos/intermine/InterMine/issues"
|
|
method: "GET"
|
|
|
|
app = express.createServer()
|
|
|
|
app.configure ->
|
|
app.use express.logger()
|
|
app.use express.bodyParser()
|
|
|
|
app.set 'view engine', 'eco'
|
|
app.set 'views', './templates'
|
|
|
|
# Register a custom .eco compiler.
|
|
app.engine 'eco', (path, options, callback) ->
|
|
fs.readFile "./#{path}", "utf8", (err, str) ->
|
|
callback eco.render str, options
|
|
|
|
app.use express.static('./public')
|
|
|
|
app.configure 'development', ->
|
|
app.use express.errorHandler
|
|
dumpExceptions: true
|
|
showStack: true
|
|
|
|
app.configure 'production', ->
|
|
app.use express.errorHandler()
|
|
|
|
# Routes
|
|
app.get '/', (req, res) ->
|
|
https.request(options, (response) ->
|
|
if response.statusCode is 200
|
|
str = ""
|
|
response.on "data", (chunk) -> str += chunk
|
|
|
|
response.on "end", ->
|
|
res.render 'index',
|
|
'issues': str
|
|
, (html) -> res.send html, 'Content-Type': 'text/html', 200
|
|
).end()
|
|
|
|
app.listen 3000
|
|
console.log "Express server listening to port 3000" |