This repository was archived by the owner on Dec 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
84 lines (64 loc) · 2.19 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
/**
* Module dependencies.
*/
var express = require('express')
, path = require('path')
, config = require('./config')
, users = require('./routes/users')
, accomplishments = require('./routes/accomplishments')
, comments = require('./routes/comments')
, timeline = require('./routes/timeline')
, hashtags = require('./routes/hashtags')
, reset = require('./routes/reset')
, socketio = require('./middleware/socketio')
, errorHandler = require('./middleware/error')
, canon = require('canonical-host')('http://pulse.illinois.edu')
, nodemailer = require('nodemailer')
, app = express();
app.set('port', process.env.PORT || 4000);
if(process.env.NODE_ENV == 'production')
app.use(canon);
app.use(express.favicon());
app.use(express.logger(process.env.NODE_ENV == 'production' ? 'default' : 'tiny'));
app.use(express.json());
app.use(express.query());
app.use(express.urlencoded());
app.use(express.cookieParser());
app.use(express.cookieSession({
secret: config.session.secret
// Keep folk logged in for a month at a time
, cookie: { maxAge: 30 * 24 * 60 * 60 * 1000 }
}));
app.use(socketio.middleware);
app.use(express.static(path.join(__dirname, 'public')));
// Logs you in
app.post('/login', users.auth);
// Logs you out
app.post('/logout', users.unauth);
// Tells you who you are logged in as
app.get('/whoami', users.whoami);
// Tells you things about a person who may/may not be registered
app.get('/whois/:netid', users.whois);
// Show all registered users
app.get('/users', users.list);
// Register a new user
app.post('/users', users.create);
// Tells you things about a user
app.get('/users/:id', users.view);
// Show all accomplishments
app.get('/accomplishments', accomplishments.list);
// Create a new accomplishment
app.post('/accomplishments', accomplishments.create);
app.post('/taunt', accomplishments.mail);
// Show comments after an accomplishment
app.get('/comments', comments.list);
// Create a comment
app.post('/comments', comments.create);
// Show all hashtags
app.get('/hashtags', hashtags.list);
// Load the timeline
app.get('/timeline', timeline.list);
if(process.env.NODE_ENV != 'production')
app.get('/reset', reset);
app.use(errorHandler);
module.exports = app;