-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
47 lines (37 loc) · 1.3 KB
/
server.js
File metadata and controls
47 lines (37 loc) · 1.3 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
const express = require('express');
const path = require('path');
const app = express();
const PORT = process.env.PORT || 3000;
// Vendor libs (three.js) — versioned by npm, safe to cache forever
app.use('/vendor', express.static(path.join(__dirname, 'node_modules/three/build'), {
maxAge: '1y',
immutable: true,
}));
// Public assets — cache for 1 hour with revalidation support
app.use(express.static(path.join(__dirname, 'public'), {
maxAge: '1h',
etag: true,
lastModified: true,
}));
app.get('/contact', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'contact.html'));
});
app.get('/devs', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'devs.html'));
});
app.get('/tos', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'tos.html'));
});
app.get('/policy', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'policy.html'));
});
app.get('/.well-known/matrix/server', (req, res) => {
res.json({ "m.server": "matrix.cns-studios.com:443" });
});
app.get('/.well-known/matrix/client', (req, res) => {
res.set('Access-Control-Allow-Origin', '*');
res.json({ "m.homeserver": { "base_url": "https://matrix.cns-studios.com" } });
});
app.listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}`);
});