-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
45 lines (36 loc) · 1.05 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
const express = require('express');
const path = require('path');
const cors = require('cors');
const demoData = require('./demo-data');
const PORT = 3000;
const app = express();
const k8scontroller = require('./controllers/k8scontroller');
app.use(express.json());
app.use(express.urlencoded());
app.use(cors());
app.get('/test-data', (req, res) => {
res.json(demoData);
});
app.get('/getPods', k8scontroller.getPods, (req, res) => {
// res.locals.result.forEach((element) => console.log('results: ', JSON.stringify(element)))
// console.log('RESULT 1: ', JSON.stringify(res.locals.result));
return res.status(200).json(res.locals.result);
});
app.get('/*', function (req, res) {
res.sendFile(
path.join(__dirname, '../PodPulse-1/public/index.html'),
function (err) {
if (err) {
res.status(500).send(err);
}
}
);
});
app.use((err, req, res, next) => {
console.log('ERROR: ', err);
return res.status(500).json(err);
});
app.listen(PORT, () => {
console.log(`Listening on port ${PORT}...`);
});
module.exports = app;