-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (23 loc) · 744 Bytes
/
app.js
File metadata and controls
29 lines (23 loc) · 744 Bytes
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
const express = require('express');
const dotenv = require('dotenv');
const proxy_router = require('./src/router');
const fs = require('fs');
dotenv.config();
const app = express();
app.use((req, res, _next) => {
res.header('Access-Control-Allow-Origin', '*');
_next();
})
proxy_router.load(app);
app.get('/', (req, res) => {
res.header('Content-Type', 'text/html');
res.end(fs.readFileSync('./public/index.html').toString('utf-8'));
})
app.use((req, res, _next) => {
res.status(403);
res.header('Content-Type', 'application/json');
res.end('{"status": false}');
});
app.listen(process.env.PORT, process.env.HOST, () => {
console.log(`Server running at http://${process.env.HOST}:${process.env.PORT}`);
});