-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp-rqra.js
141 lines (108 loc) · 6.24 KB
/
app-rqra.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
process.setMaxListeners(0);//annoying.
var express = require('express');
var routesCommon = require('./routes/common/routesCommon.js');
var routesRqra = require('./routes/rqra/routesRqra.js');
//var Notification = require("./controller/NotificationAction.js");
var app = module.exports = express.createServer();
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.session({ secret: "keyboard cat",
store: express.session.MemoryStore({ reapInterval: 60000 })
}));
//app.use(express.csrf());
app.use(app.router);
app.use(express.static(__dirname + "/public"));
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
app.dynamicHelpers({
token: function(request, response) {
return request.session._csrf;
}
});
// routing
app.get('/', routesRqra.index);
app.get('/prof', routesRqra.prof);
app.get('/login', routesRqra.login);
app.get('/logout', routesCommon.logout);
// main views
app.get('/questions', routesRqra.questionListPage);
app.get('/question/:id', routesRqra.questionDetailsPage);
app.get('/new', routesRqra.questionFormPage);
// components
app.get('/component/header', routesRqra.header);
app.get('/component/courses', routesRqra.courseList);
app.get('/component/timeline', routesRqra.timeline);
app.get('/component/questions', routesRqra.questionList);
app.get('/component/question', routesRqra.questionDetails);
app.get('/component/new', routesRqra.questionForm);
app.get('/component/notification', routesRqra.notificationList);
// user
app.get('/api/user/courses', routesCommon.userCourses); // gets a list of all the users courses
app.get('/api/user/:id', routesCommon.user); // get user by id
app.post('/api/users/', routesCommon.userQuery); // get a list of users based on a custom query
app.put('/api/user/setPreferedName', routesCommon.userPreferredName); // update users prefered name
app.get('/api/course/:id/members', routesCommon.courseMembers);
// course
app.get('/api/course/:id', routesCommon.course); // get course by id
app.post('/api/courses/', routesCommon.courseQuery); // get a list of courses based on a custom query
app.get('/api/course/:id/instructor', routesCommon.courseInstructor); // get the instructor of a course
app.post('/api/course/sections', routesCommon.sectionsInCourse); // gets a list of the section uids for a given course
// notification
app.get("/api/user/notification/:uid", routesRqra.getUserNotifications);
app.put("/api/user/notification", routesRqra.updateUserNotifications);
app.delete("/api/user/notification/:uid/:qid", routesRqra.removeCommentNotifier);
// questions
//TODO: need update this into document
app.post("/api/question", routesRqra.question); // post a new question by user id stored in seesion
//TODO: need update this into document
app.put("/api/questions/:uid/views", routesRqra.questionViewCount); // increase view count
app.get("/api/questions/instructor/page/:page", routesRqra.instructorQuestions); //get all instructor questions
app.get("/api/questions/page/:page", routesRqra.questions); //P, get all questions
app.get("/api/questions/unanswered/page/:page", routesRqra.questionsUnanswered); //P, get all unanswered questions
app.get("/api/questions/new/page/:page", routesRqra.questionsNew); //P get all new questions
app.get("/api/questions/answered/page/:page", routesRqra.questionsAnswered); //P
app.get("/api/question/:uid", routesRqra.question); // get question by id
app.put("/api/question/:uid", routesRqra.question); // update question by id
app.delete("/api/question/:uid", routesRqra.question); // update question by id
app.get("/api/user/:uid/questions/page/:page", routesRqra.questionsByUser); // P, get all questions for a user. TODO:sort desc
//deprecated, we do not need :uid when user post a new question
//app.post("/api/user/:uid/questions", routesRqra.questionsByUser); // user posts a new question
//TODO: need update this into document
app.put("/api/question/:uid/follow", routesRqra.followQuestion); // a follower follows a question
//TODO: need update this into document
app.put("/api/question/:uid/unfollow", routesRqra.unfollowQuestion); // a follower follows a question
//TODO: this going to be deprecated, becuase we do not need ":follower"
//app.put("/api/question/:uid/follow/:follower", routesRqra.followQuestion); // a follower follows a question
app.put("/api/question/:uid/status", routesRqra.questionStatus); // updates a questions status
app.post("/api/search/page/:page", routesRqra.search); // search based on a query
// comments
//TODO: need update this into document
app.post("/api/comment",routesRqra.comment); // post a new comment by user id stored in seesion object
app.get("/api/comments/page/:page", routesRqra.comments); //P get all comments
app.delete("/api/comments/", routesRqra.comments);
app.get("/api/comment/count/:uid", routesRqra.commentCount);
app.get("/api/comment/:uid", routesRqra.comment); // get a comment by id
app.put("/api/comment/:uid", routesRqra.comment); // updates a question by id
app.delete("/api/comment/:uid", routesRqra.comment); //deletes a comment by id
app.get("/api/user/:uid/comments/page/:page", routesRqra.commentsByUser); //P gets a list of comments posted by a user
//deprecated
//app.post("/api/user/:uid/comments", routesRqra.commentsByUser); // user posts a comment
app.put("/api/comment/:uid/vote/:dir", routesRqra.commentVote); // votes on a comment
app.put("/api/comment/:uid/answered", routesRqra.commentAnswered); // updates a comments status to answered
app.get("/api/question/:uid/comments/page/:page", routesRqra.commentsByQuestion); // P get all of the comments for a question
//userprofile
app.get("/api/user/:id/profile",routesCommon.userProfile); //get user profile by id
app.put("/api/user/:id/profile",routesCommon.userProfile); //update user profile by id
/***NEW ROUTES */
app.post("/api/questions/search/page/:page", routesRqra.searchQuestionsRoute);
app.get("/api/week/:id", routesRqra.getWeekByCourseId); //course ID
app.post("/api/week", routesRqra.addWeek) //add week , provide {course, week, topic} in JSON
app.post("/api/setSelectedCourse", routesRqra.setSelectedCourse);