-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
56 lines (39 loc) · 1.26 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
43
44
45
46
47
48
49
50
51
52
53
54
import express from 'express';
import cors from 'cors';
import path from 'path';
import { fileURLToPath } from 'url';
import router from './api/apiRoutes.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = express();
let url = process.env.PHOENIX_API_URL
const port = 3000;
const corsOptions = {
origin: url,
methods: 'GET,POST,OPTIONS',
allowedHeaders: 'Content-Type,Authorization'
};
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors(corsOptions));
app.use('/views', express.static(path.join(__dirname, 'views')));
app.use('/public', express.static(path.join(__dirname, 'public')));
app.get('/', (req, res) => {
res.render('dashboard');
// res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
app.get('/home', (req, res) => {
res.render('dashboard');
});
app.get('/health/interface', (req, res) => {
res.status(200).json({ status: 'OK', message: 'Interface is healthy' });
});
app.get('/login', (req, res) => {
res.render('login');
});
app.use('/api', router);
app.listen(port, () => {
console.log(`Lightning wallet UI app listening at http://localhost:${port}`);
});