Skip to content

Commit

Permalink
Add web interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Kruijsen committed Mar 5, 2013
1 parent 0dedb4b commit b66e401
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: coffee web.coffee
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dependencies": {
"coffee-script": "*",
"flatiron": "*",
"union": "*",
"csv": "*",
"async": "*",
"node-zip": "*",
Expand Down
25 changes: 25 additions & 0 deletions web.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
flatiron = require 'flatiron'
dbToJson = require('./lib/lib').dbToJson
Location = require('./lib/models').Location

app = flatiron.app

app.use flatiron.plugins.http, {}

app.config.env()
app.config.defaults({
'MONGOHQ_URL': 'mongodb://localhost:27017/waterstanden-dev'
})

Location.connect(app.config.get('MONGOHQ_URL'))

read = ->
dbToJson (error, json) =>
Location.db.close()
@res.writeHead(200, {'Content-Type': 'application/json'})
@res.write JSON.stringify(json)
@res.end()

port = process.env.PORT || 5000
app.router.get '/', read
app.listen(port)

0 comments on commit b66e401

Please sign in to comment.