Skip to content

Commit

Permalink
print peerServer url on mount
Browse files Browse the repository at this point in the history
express app settings retrieves its env value NODE_ENV
Heroku defaults set NODE_ENV to production
  • Loading branch information
David Solis committed Jan 9, 2021
1 parent b50e5c2 commit 2212a23
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ app.use(cors(corsOptions))

const peerServer = ExpressPeerServer(app.listen(PORT), { key: KEY })

peerServer.on('mount', (app: Application) => {
let url: string
if (app.settings.env === 'development') {
url = `http://localhost:${PORT}/${KEY}`
} else {
url = `https://pintopinto.herokuapp.com/${KEY}`
}
console.log(`Started ExpressPeerServer on: ${url}`)
})

app.use(`/${KEY}`, peerServer)

// GET:- Redirect to welcome page
Expand Down

0 comments on commit 2212a23

Please sign in to comment.