-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
93 lines (71 loc) · 2.37 KB
/
app.js
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
82
83
84
85
86
87
88
89
90
91
92
93
// Generated by CoffeeScript 1.3.3
(function() {
var app, config, db, express, google, jade, portfolio;
express = require('express');
jade = require('jade');
google = require('./reader');
config = require('./config');
portfolio = require('./portfolio');
db = require('mongojs').connect('mongodb://nodejitsu:[email protected]:10072/nodejitsudb4055495529', ['users']);
google.config(config.google);
app = express();
app.configure(function() {
app.set('view engine', 'jade');
app.set('views', "" + __dirname + "/views");
app.set('port', process.env.PORT || 3000);
app.use(express.bodyParser());
app.use(express["static"](__dirname + '/public'));
app.use(express.cookieParser());
app.use(express.session({
secret: "shhhhhhhhhhhhhh!"
}));
app.use(express.methodOverride());
return app.use(app.router);
});
app.configure('development', function() {
return app.use(express.errorHandler({
dumpExceptions: true,
showStack: true
}));
});
app.configure('production', function() {
return app.use(express.errorHandler());
});
app.get('/', function(req, res) {
portfolio.sync(null, null, function(resp) {
return console.log(resp);
});
/*
google.listFiles null, (resp) ->
portfolio.create resp, (arr) ->
console.log arr
for item in resp.items
if item.file and item.file.parents and item.file.parents[0]
console.log item.file if item.file.parents[0].id is '0BwF9Jd0AjOqgcVNtVlNrV3hweVE'
# if item.file.parents and item.file.parents[0].id
# item.file.parents #
google.listFiles null, (resp) ->
portfolio.create resp, (arr) ->
console.log arr
*/
return res.render('index', {
title: 'Hello World!'
});
});
app.get('/auth', function(req, res) {
return google.auth(function(resp) {
return res.redirect(resp);
});
});
app.get('/oauth2callback', function(req, res) {
return google.getToken(req.query.code, function(resp) {
req.session.google = resp;
return res.redirect('/pick-name');
});
});
app.get('/pick-name', function(req, res) {
return res.render('username');
});
app.listen(app.get('port'));
console.log("Express server listening on port " + (app.get('port')));
}).call(this);