forked from ernestpasnik/cs2d-serverlist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
50 lines (44 loc) · 1.14 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
require('console-stamp')(console, 'HH:MM:ss.l')
const servers = require(__dirname + '/src/servers')
const express = require('express')
const minifyHTML = require('express-minify-html-2')
const app = express()
const port = 3000
app.set('view engine', 'ejs')
app.use(express.static('public'))
app.use(minifyHTML({
override: true,
exception_url: false,
htmlMinifier: {
removeComments: false,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeEmptyAttributes: true,
minifyJS: true
}
}))
app.get('/', (req, res) => {
const data = servers.getData()
res.render('serverlist', {
servers: data.servers.length,
players: data.players,
svlst: data.servers
})
})
app.get('/details/:address', (req, res) => {
res.render('details', {
sv: servers.getServer(req.params.address)
})
})
app.get('/api', (req, res) => {
res.render('api', {
example: servers.getServer('54.38.156.49:36963')
})
})
app.get('/api/:address', (req, res) => {
res.json(servers.getServer(req.params.address))
})
app.listen(port, () => {
console.log(`CS2D Serverlist listening on port ${port}`)
})