Newer
Older
import express from "express"
import http from "http"
import process from "process"
import signalbuddy from "signalbuddy"
const host = "127.0.0.1"
const port = process.env.PORT || 3000
const app = express()
const server = http.createServer(app)
const config = {
rooms: {
maxClients: 0, // no limit
},
stunCount: 2,
turnCount: 0,
}
signalbuddy(server, config)
app.use((request, response, next) => {
response.on("finish", () => {
console.log(
"[%s] [%s]: %s %s",
`${new Date()}`.split(" ", 5).join(" "),
response.statusCode,
request.method.padStart(7),
request.originalUrl,
)
})
next()
})
app.use("/", express.static("public"))
server.listen(port, host, () => {
console.log(`Listening on http://${host}:${port}`)
process.on("SIGINT", process.exit)