-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
42 lines (38 loc) · 1.22 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
const express = require('express')
const path = require('path')
const stringify = require('json-stringify-safe')
module.exports = ({ socketPort, config = {}, baseUrl = '', bundles = [] }) => {
const server = express()
const stringConfig = stringify(config, null, 2)
server
.disable('x-powered-by')
.use(express.static(path.join(__dirname, '.build')))
.get('/*', (req, res) => {
res.status(200).send(`
<!doctype html>
<html lang="">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charSet='utf-8' />
<title>Microverse Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Rubik:300,400,500" rel="stylesheet" type="text/css" />
<link href="${baseUrl}/style.css" rel="stylesheet" type="text/css" />
</head>
<body class="with-content-panel">
<div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js"></script>
<script>
var __microverse = {
socketPort: ${socketPort},
bundles: ${JSON.stringify(bundles)},
config: ${stringConfig},
}
</script>
<script src="${baseUrl}/bundle.js"></script>
</body>
</html>
`)
})
return server
}