You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.1 KiB
45 lines
1.1 KiB
const express = require('express'); |
|
const helmet = require('helmet'); |
|
const compression = require('compression'); |
|
const app = express(); |
|
const port = 3000; |
|
const path = require('path'); |
|
|
|
require('dotenv').config(); |
|
|
|
app.set('views', __dirname + '/views'); |
|
app.set('view engine', 'jsx'); |
|
app.engine('jsx', require('express-react-views').createEngine()); |
|
app.use(express.static(path.join(__dirname, '/public'))); |
|
app.use( |
|
helmet({ |
|
referrerPolicy: false, |
|
contentSecurityPolicy: false, |
|
}) |
|
); |
|
app.use(compression()); |
|
|
|
const db = require('./database.js'); |
|
|
|
async function db_all(query) { |
|
return new Promise(function (resolve, reject) { |
|
db.all(query, function (err, rows) { |
|
if (err) { |
|
return reject(err); |
|
} |
|
resolve(rows); |
|
}); |
|
}); |
|
} |
|
|
|
app.get('/', async (req, res) => { |
|
const sql = `SELECT * FROM netmonResults`; |
|
const dbdata = await db_all(sql); |
|
res.render('index', { dbdata }); |
|
}); |
|
|
|
app.listen(port, () => { |
|
console.log( |
|
`app listening at http://localhost:${port} in ${app.settings.env} mode. netmon is monitoring ${process.env.dstHost}` |
|
); |
|
});
|
|
|