Add server-side logging and timeout option (#366)
This commit is contained in:
parent
7635375471
commit
8b2276a7ae
1 changed files with 15 additions and 1 deletions
16
server.js
16
server.js
|
|
@ -16,9 +16,23 @@ try {
|
|||
const app = express()
|
||||
|
||||
const isProd = process.argv.includes('--prod') || process.env.NODE_ENV === 'production'
|
||||
const timeoutIndex = process.argv.indexOf('--timeout')
|
||||
let timeout = timeoutIndex > -1 && timeoutIndex + 1 < process.argv.length
|
||||
? parseInt(process.argv[timeoutIndex + 1])
|
||||
: process.env.TIMEOUT
|
||||
? parseInt(process.env.TIMEOUT)
|
||||
: 10000
|
||||
if (isNaN(timeout) || timeout < 0) {
|
||||
console.warn('Invalid timeout value provided, using default of 10000ms')
|
||||
timeout = 10000
|
||||
}
|
||||
app.use(compression())
|
||||
app.use(cors())
|
||||
app.use(netApi({ allowOrigin: '*' }))
|
||||
app.use(netApi({
|
||||
allowOrigin: '*',
|
||||
log: process.argv.includes('--log') || process.env.LOG === 'true',
|
||||
timeout
|
||||
}))
|
||||
if (!isProd) {
|
||||
app.use('/sounds', express.static(path.join(__dirname, './generated/sounds/')))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue