forked from Namaneo/Junie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
30 lines (23 loc) · 959 Bytes
/
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
const fs = require('fs');
const express = require('express');
const cors = require('cors');
const compression = require('compression');
const static = require('serve-static');
const directory = require('serve-index');
const app = express();
app.use(cors());
app.use(compression({ filter: () => true }));
app.use('/assets', static('./assets'))
app.use('/system', static('./system'))
app.use('/games', static('./games'))
const web_src_path = "./libRetroReversing/websrc/dist/" || "./bin";
const index_html_path = "./libRetroReversing/websrc/dist/index.html" || './bin/index.html';
app.use('/', directory('./games'), (req, res) => {
const full_path = web_src_path + req.path;
const file = fs.existsSync(full_path)
? full_path
: index_html_path;
res.sendFile(file, { root: __dirname });
});
const port = process.env.PORT || 8000;
app.listen(port, () => console.log(`Server running on port ${port}`));