-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.coffee
62 lines (53 loc) · 1.76 KB
/
server.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
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
# Requires and Variables
exp = require 'express'
app = exp.createServer()
passport = require 'passport'
TwitterStrategy = require('passport-twitter').Strategy
User = require('./models/user.coffee').User
stylus = require 'stylus'
# compile on the fly
require 'coffee-script'
require('./apps/socket-io')(app)
callBackURL = (serviceName) ->
if process.env.PORT
domain = 'http://devspect.com'
else
domain = 'http://localhost:1337'
url = "#{domain}/auth/#{serviceName}/callback"
passport.use new TwitterStrategy {
consumerKey: '1301yY5d1qQD5HWVYtAA',
consumerSecret: 'iEo7n9756AesXzjborhu8LDXTWR53TEz4Y3T8WDe4',
callbackURL: callBackURL('twitter') },
(token, tokenSecret, profile, done) ->
console.log "User is #{profile.id} / #{profile.username}"
user = new User profile.username
user.validate (err, user) ->
done(null, user)
passport.serializeUser (user, done) ->
done null, user
passport.deserializeUser (user, done) ->
done null, user
# App Configuration
app.configure () ->
app.set 'view engine', 'jade'
app.set 'view options', { layout: false }
app.set 'views', __dirname + '/views'
app.use exp.static __dirname + '/public'
app.use exp.bodyParser()
app.use exp.methodOverride()
app.use exp.cookieParser()
app.use exp.session({secret: "DevSpect-For-All-My-Friends"})
app.use passport.initialize()
app.use passport.session()
# Run App
app.listen process.env.PORT || 1337
console.log "Server running at http://localhost:#{app.address().port}/"
# Global Helpers
require('./apps/helpers')(app)
# Routes
require('./apps/auth/routes')(app, passport)
require('./apps/cfd/routes')(app)
require('./apps/cycle_time/routes')(app)
require('./apps/velocity/routes')(app)
require('./apps/burn/routes')(app)
require('./apps/home/routes')(app)