This repository was 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
Expand file tree
/
Copy pathserver.js
More file actions
104 lines (78 loc) · 2.83 KB
/
server.js
File metadata and controls
104 lines (78 loc) · 2.83 KB
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
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: '/questions', changefreq: 'daily', priority: 0.3 },
{ url: '/proposals/', 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: '/about/', changefreq: 'weekly', priority: 0.7 },
{ url: '/faqs/', changefreq: 'weekly', priority: 0.7 },
{ url: '/privacy-policy', changefreq: 'monthly', priority: 0.7 }
]
});
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname + '/index.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 + '/query.html'))
})
app.get('/:category/@:username/:permLink', function (req, res) {
res.sendFile(path.join(__dirname + '/query.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('/about', function (req, res) {
res.sendFile(path.join(__dirname + '/about.html'))
})
app.get('/privacy-policy', function (req, res) {
res.sendFile(path.join(__dirname + '/privacy-policy.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}`)
});