-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (27 loc) · 930 Bytes
/
index.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 Koa = require('koa');
const app = new Koa();
const db = require('./db')
const KeysController = require('./api/controllers/keys')
db.init()
require('./api')(app)
// Disable caching
app.use(async (ctx, next) => {
await next()
ctx.set('Cache-Control', 'no-store, no-cache, must-revalidate')
ctx.set('Pragma', 'no-cache')
ctx.set('Expires', 0)
})
// Try to generate new keys in case this is a first-time run
KeysController.generateKeys()
.then(results => {
if (results.firstTimeKeys) {
console.log('This is the first time you run Pihole Cluster Manager, SSH keys have been generated')
}
})
.catch(error => {
console.error('There was an error generating the SSH keys, please check file permissions start the application again.')
console.error(error)
})
app.listen(3000, () => {
console.log('PiHole Cluster Manager is listening on port 3000')
});