aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions
e>
3e900e0b ^
74978738 ^



da65bcb2 ^
5d56b2ef ^

98a44809 ^

da65bcb2 ^
c5d381e2 ^
3e900e0b ^



da65bcb2 ^

5d56b2ef ^
da65bcb2 ^


3e900e0b ^
a189adff ^
74978738 ^






fe4f8092 ^



98a44809 ^




c5d381e2 ^
fe4f8092 ^
3e900e0b ^
d37bc943 ^





74978738 ^


39a01809 ^
74978738 ^

d37bc943 ^
3e900e0b ^
74978738 ^

16062edf ^
74978738 ^

c5d381e2 ^
74978738 ^

3e900e0b ^
74978738 ^


3e900e0b ^
c5d381e2 ^




16062edf ^
3e900e0b ^
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
                            

                                
                                
 



                                                 
 

                                              

               
                         
                                            



                                                 

                               
                                                                                               


                              
 
        






                                    



                                




                              
     
                 
 





                                            


                                       
 

                                   
                                    
 

                                             
 

                                           
 

                                                  
 


                                                                 
 




                                
 
                
express = require('express')
path = require('path')
engines = require('consolidate')
passport = require('./passport')

calculator = require("./routes/calculator")
sessions = require("./routes/sessions")(passport)
transactions = require("./routes/transactions")
users = require("./routes/users")

RedisStore = require('connect-redis')(express)
sessionStore = new RedisStore()

app = express()
app.enable('trust proxy')
app.engine('html', require('mmm').__express)
app.set('view engine', 'html')
app.set('views', __dirname + '/views')
app.use(express.static(__dirname + '/public'))
app.use(require('connect-assets')(src: 'public'))
app.use(express.bodyParser())
app.use(express.cookieParser())
app.use(express.session(secret: 'weareallmadeofstars', store: sessionStore, key: 'vanbtc.sid'))
app.use(passport.initialize())
app.use(passport.session())
app.use(app.router)

routes =
  "/": 'main/index'
  "/about": 'main/about'
  "/exchangers": 'main/exchangers'
  "/exchangers/join": 'main/join'
  "/merchants": 'main/merchants'
  "/merchants/signup": 'main/signup'
  "/contact": 'main/contact'

for route, view of routes
  ((route, view) ->
    app.get(route, (req, res) ->
      res.render(view, 
        js: (-> global.js), 
        css: (-> global.css), 
        layout: 'layout'
      )
    )
  )(route, view) 

authorize = (req, res, next) ->
  return next() if req.isAuthenticated() and
    req.params.user is req.user.username or 
    req.user.username is 'admin'
  res.redirect('/login')

app.get('/setup', calculator.new)
app.get('/calculator', calculator.show)
app.get('/ticker', calculator.ticker)

app.get('/login', sessions.new)
app.post('/login', sessions.create)
app.get('/logout', sessions.destroy)

app.get('/:user.json', authorize, users.json)
app.get('/:user', authorize, users.show)

app.get('/users/new', authorize, users.new)
app.post('/users', authorize, users.create)

app.get('/:user/edit', authorize, users.edit)
app.post('/:user/update', authorize, users.update)

app.get('/:user/transactions.json', authorize, transactions.json)
app.post('/:user/transactions', authorize, transactions.create)
app.get('/:user/report', authorize, transactions.index)

app.use((err, req, res, next) ->
  res.status(500)
  console.log(err)
  res.end()
)

app.listen(3000)