-
Notifications
You must be signed in to change notification settings - Fork 2
/
myapp.coffee
33 lines (26 loc) · 942 Bytes
/
myapp.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
express = require 'express'
module.exports = class MyApp
constructor:(@graphDb)->
graphDb = @graphDb
app = express.createServer express.logger()
app.configure ->
app.set 'views', __dirname + '/public'
app.set 'view options', layout:false
app.use express.methodOverride()
app.use express.bodyParser()
app.use app.router
indexPromise = graphDb.index.createNodeIndex "myIndex"
indexPromise.then((index)->
app.get '/', (request, response)->
index.query("name:*").then((nodes)->
response.render 'index.jade', nodes:nodes
)
app.post '/', (request, response)->
name = request.body.name
node = graphDb.node {name:name}
index.index(node, "name", name).then(()->
response.redirect "/"
)
)
port = process.env.PORT || 3000
app.listen port, -> console.log("Listening on " + port)