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.
63 lines
1.6 KiB
63 lines
1.6 KiB
const path = require('path')
|
|
const express = require('express')
|
|
const app = express()
|
|
const logger = require('morgan')
|
|
const cookieParser = require('cookie-parser')
|
|
const bodyParser = require('body-parser')
|
|
const opn = require('opn')
|
|
|
|
const booth = require('./booth')
|
|
|
|
const CFG = require('../config')
|
|
const PKG = require('../package')
|
|
|
|
// view engine setup
|
|
app.set('views', path.join(__dirname, 'views'))
|
|
app.set('view engine', 'ejs')
|
|
app.use(logger('dev'))
|
|
app.use(bodyParser.json())
|
|
app.use(bodyParser.urlencoded({ extended: false }))
|
|
app.use(cookieParser())
|
|
app.use(express.static(path.join(__dirname, 'public')))
|
|
|
|
app.use('/booth', booth)
|
|
|
|
app.get('/', (req, res) => {
|
|
res.render('index', {
|
|
serverIpAddress: CFG.server.ipAddress,
|
|
serverPort: CFG.server.port
|
|
})
|
|
})
|
|
|
|
app.get('/test', (req, res) => {
|
|
res.render('test', {
|
|
serverIpAddress: CFG.server.ipAddress,
|
|
serverPort: CFG.server.port
|
|
})
|
|
})
|
|
|
|
app.get('/bobinoscope', (req, res) => {
|
|
res.render('scope', {
|
|
serverIpAddress: CFG.server.ipAddress,
|
|
serverPort: CFG.server.port,
|
|
killZone: CFG.killZone,
|
|
renderingTime: 5000
|
|
})
|
|
})
|
|
|
|
module.exports = function (pArgs) {
|
|
let server = app.listen(CFG.server.port, () => {
|
|
console.log(`[-] Server running on: ${CFG.server.ipAddress}:${CFG.server.port}`)
|
|
})
|
|
// Socket Io
|
|
app.locals.io = require('socket.io')(server)
|
|
booth.setSocketIo(app.locals.io)
|
|
|
|
if (!pArgs.noc) {
|
|
console.log(`[-] Starting chromium...`)
|
|
opn('http://localhost:3111/bobinoscope', {
|
|
app: ['chromium-browser', '--app=http://localhost:3111/bobinoscope', '--start-fullscreen', '--password-store=basic']
|
|
})
|
|
}
|
|
return app
|
|
}
|