This repository has been archived by the owner on May 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
131 lines (95 loc) · 3.39 KB
/
server.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
const path = require('path')
var express = require('express');
var app = express();
var sm = require('sitemap');
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.join(__dirname, 'public')));
var sitemap = sm.createSitemap ({
hostname: 'https://www.peerquery.com',
cacheTime: 600000, // 600 sec - cache purge period
urls: [
{ url: '/', changefreq: 'daily', priority: 0.3 },
{ url: '/about/', changefreq: 'daily', priority: 0.3 },
{ url: '/proposals/', changefreq: 'daily', priority: 0.3 },
{ url: '/questions', changefreq: 'daily', priority: 0.3 },
{ url: '/contests/', changefreq: 'daily', priority: 0.3 },
{ url: '/quizzes/', changefreq: 'daily', priority: 0.3 },
{ url: '/gigs/', changefreq: 'daily', priority: 0.3 },
{ url: '/tags/', changefreq: 'daily', priority: 0.3 }
]
});
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname + '/index.html'))
})
app.get('/about', function (req, res) {
res.sendFile(path.join(__dirname + '/about.html'))
})
app.get('/questions', function (req, res) {
res.sendFile(path.join(__dirname + '/questions.html'))
})
app.get('/proposals', function (req, res) {
res.sendFile(path.join(__dirname + '/proposals.html'))
})
app.get('/contests', function (req, res) {
res.sendFile(path.join(__dirname + '/contests.html'))
})
app.get('/quizzes', function (req, res) {
res.sendFile(path.join(__dirname + '/quizzes.html'))
})
app.get('/gigs', function (req, res) {
res.sendFile(path.join(__dirname + '/gigs.html'))
})
app.get('/user', function (req, res) {
res.sendFile(path.join(__dirname + '/user.html'))
})
app.get('/tags', function (req, res) {
res.sendFile(path.join(__dirname + '/tags.html'))
})
app.get('/tag/:tag', function (req, res) {
res.sendFile(path.join(__dirname + '/tag.html'))
})
app.get('/@:username/feed', function (req, res) {
res.sendFile(path.join(__dirname + '/feed.html'))
})
app.get('/@:username/community', function (req, res) {
res.sendFile(path.join(__dirname + '/community.html'))
})
app.get('/@:username/wallet', function (req, res) {
res.sendFile(path.join(__dirname + '/wallet.html'))
})
app.get('/publish', function (req, res) {
res.sendFile(path.join(__dirname + '/publish.html'))
})
app.get('/me', function (req, res) {
res.sendFile(path.join(__dirname + '/me.html'))
})
app.get('/@:username', function (req, res) {
res.sendFile(path.join(__dirname + '/user.html'))
})
app.get('/@:username/:permLink', function (req, res) {
res.sendFile(path.join(__dirname + '/post-view.html'))
})
app.get('/:category/@:username/:permLink', function (req, res) {
res.sendFile(path.join(__dirname + '/post-view.html'))
})
app.get('/sitemap.xml', function(req, res) {
sitemap.toXML( function (err, xml) {
if (err) {
return res.status(500).end();
}
res.header('Content-Type', 'application/xml');
res.send( xml );
});
});
app.use(function (req, res) {
res.status(404).sendFile(path.join(__dirname + '/404.html'))
})
var port = process.env.PORT || 80;
app.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`)
});