-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
96 lines (88 loc) · 3.57 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
var express = require('express');
var session = require('express-session')
var routes = require('./routes/routes.js');
var chats = require('./routes/chats.js');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var multer = require('multer');
var upload = multer({ storage: multer.memoryStorage() });
app.use(express.urlencoded());
app.use(session({
secret: 'asdf',
resave: false,
saveUninitialized: true,
cookie: { secure: false }
}));
app.use(express.static('public'));
// Socket related code
io.on("connection", function(socket){
socket.on("chat message", function(obj){
io.to(obj.room).emit("chat message", obj);
});
socket.on("join room", function(obj){
socket.join(obj.room);
});
socket.on("leave room", function(obj){
socket.leave(obj.room);
});
});
// Routes for everything except chat
app.get('/', routes.get_login);
app.post('/checklogin', routes.check_login);
app.get('/getstate', routes.get_state);
app.get('/setstate', routes.set_state);
app.post('/updateaffiliation', routes.update_affiliation);
app.post('/updateemail', routes.update_email);
app.post('/updatepassword', routes.update_password);
app.post('/updatevisibility', routes.update_visibility);
app.post('/updateinterests', routes.update_interests);
app.get('/signup', routes.signup);
app.post('/createaccount', routes.create_account);
app.get('/profile', routes.get_profile);
app.get('/home', routes.get_home);
app.get('/refreshhome', routes.get_refresh_home);
app.get('/wall', routes.get_wall);
app.get('/refreshwall', routes.get_refresh_wall);
app.post('/wallpost', routes.wall_post);
app.post('/comment', routes.comment);
app.get('/comments', routes.get_comments);
app.post('/createfriendrequest', routes.create_friend_request);
app.post('/undofriendrequest', routes.undo_friend_request);
app.post('/unfriend', routes.unfriend);
app.get('/search', routes.search);
app.get('/refreshsearch', routes.refresh_search);
app.get('/getautocomplete', routes.get_autocomplete);
app.get('/logout', routes.logout);
app.post('/upload', upload.single('myFile'), routes.upload);
app.get('/getimage', routes.get_image);
app.get('/friendvisualizer', routes.friend_visualizer);
app.get('/sendvisualizer', routes.send_visualizer);
app.get('/friendvisualization', routes.friend_visualization);
app.get('/getFriends/:user', routes.get_friends);
app.post('/acceptrequest', routes.accept_request);
app.post('/rejectrequest', routes.reject_request);
app.get('/articlesearch', routes.article_search);
app.post('/articlelike', routes.article_like);
app.get('/checkinactive', routes.check_inactive);
app.get('/newsalgorithm', routes.news_algorithm);
// Chat related routes
app.get('/chats', chats.get_chat);
app.post('/postMessage', chats.post_message);
app.get('/startchat', chats.get_startchat);
app.get('/getchatinvites', chats.get_chat_invites);
app.get('/getuserchats', chats.get_user_chats);
app.get('/getonlinefriends', chats.get_online_friends);
app.get('/getgroupchatinvite', chats.get_group_chat_invite);
app.get('/getonlinefriendssimple', chats.get_online_friends_simple);
app.post('/postacceptchat', chats.post_accept_chat);
app.post('/postrejectchat', chats.post_reject_chat);
app.post('/postacceptgroupchat', chats.post_accept_group_chat);
app.post('/postrejectgroupchat', chats.post_reject_group_chat);
app.get('/getonlinefriends', chats.get_online_friends);
app.post('/postchatinvite', chats.post_chat_invite);
app.post('/postgroupchatinvite', chats.post_group_chat_invite);
app.post('/leaveroom', chats.leave_room);
/* Run the server */
http.listen(80);
console.log('Server running on port 80');