forked from FieldDB/FieldDB
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
55 lines (49 loc) · 1.92 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
var express = require('express')
,everyauth = require('everyauth')
,util = require('util')
,https = require('https')
,crypto = require('crypto')
,fs = require('fs')
,users = require('./lib/users');
var authconf = require('./everyauthconfig');
var apphttpsdomain = "https://localhost:3001";
everyauth.twitter
.consumerKey(authconf.twitter.consumerKey)
.consumerSecret(authconf.twitter.consumerSecret)
.findOrCreateUser(function(session, accessToken, accessTokenSecret, twitterUserData) {
var promise = this.Promise();
users.findOrCreateByTwitterData(twitterUserData, accessToken, accessTokenSecret, promise);
return promise;
})
.redirectPath(apphttpsdomain+'#user');
var httpsOptions ={
key: fs.readFileSync('ifield.key'),
cert: fs.readFileSync('ifield.crt')};
var app = express.createServer(httpsOptions);
app.configure(function() {
app.use(express.logger());
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.session({secret: "90ndsj9dfdsfwewfead3"}));
app.use(everyauth.middleware());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
app.use(express.errorHandler());
everyauth.helpExpress(app);
});
app.get('/c/:usergeneric/:corpusordatalist', function(req, res){
console.log("hi");
var usergeneric = req.params.usergeneric
, corpusordatalist = req.params.corpusordatalist;
var corpusid = "";
//TOOD look up the usergeneric, then look up the corpus id so that the backbone router will show/fetch that corpus.
// res.redirect(apphttpsdomain+'#corpus/'+corpusid);
res.send('usergeneric ' + req.params.usergeneric+ ', corpusordatalist '+req.params.corpusordatalist);
});
app.get('/u/:usergeneric', function(req, res){
console.log("Got a route");
res.redirect("https://localhost:3001\#user/"+req.params.usergeneric);
});
port = "3001";
app.listen(port);
console.log("Listening on " + port)