forked from alabid/flylatex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
119 lines (88 loc) · 3.03 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/**
* Module dependencies.
* app.js -
* entry to express app.
*
*/
var express = require('express')
, app = module.exports = express.createServer()
, sharejs = require('share').server
, routes = require('./routes')
, MongoStore = require('connect-mongo')(express);
// Global server Configuration
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({
secret: "788e6139b25d14de5eecc7fc14bd65529218e8cc",
store: new MongoStore({
db: "user-auth"
})
}));
app.use(app.router);
app.use(express.static(__dirname + '/public'));
}).dynamicHelpers({
info: function(req, res) {
return req.flash('info');
},
error: function(req, res) {
return req.flash('error');
}
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
// ========= ShareJS configuration ============
// attach the sharejs REST and socket.io interfaces to the server
var sharejsOptions = {db: {type: 'none'}};
sharejs.attach(app, sharejsOptions);
/**
* Routes
*/
app.post('/', routes.preIndex, routes.index);
app.get('/', routes.preIndex, routes.index);
app.del('/', routes.logOutUser, routes.index);
// for signing up on site
app.get('/signup', routes.displaySignUpForm);
app.post('/signup', routes.processSignUpData);
// for creating a new document
app.put('/createdoc', routes.createDoc);
// for deleting a document
app.del('/deletedoc', routes.deleteDoc);
// for sharing access to a document
app.post('/shareaccess', routes.shareAccess);
// for requesting access to a document
app.post('/requestaccess', routes.requestAccess);
// for requesting auto-complete data
app.get('/autocomplete', routes.ajaxAutoComplete);
// for getting messages for a user
app.get('/showmessages', routes.getMessages);
// for granting access to a document
app.post('/grantaccess', routes.grantAccess);
// for accepting invitation to have access to a document
app.post('/acceptaccess', routes.acceptAccess);
// add a new document to my list of sessions
app.post('/adddoctosession', routes.addNewDocument);
// reload the documents in the session of the current user
app.post('/reloadsession', routes.reloadSession);
// delete a message
app.post('/deletemessage', routes.deleteMessage);
// load a document
app.get('/document/:documentId', routes.preIndex, routes.openDocument);
// save the text for a document
app.post('/savedoc', routes.saveDocument);
// compile the latex document
app.post('/compiledoc', routes.compileDoc);
// for serving pdf's for documents with specific id's
app.get('/servepdf/:documentId', routes.servePDF);
/** end of ROUTES */
// open a port for this server
app.listen((process.env.PORT || 3000), function(){
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
});