Skip to content

Commit

Permalink
Update app.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ookamiiixd authored Jun 21, 2022
1 parent 5175c6b commit b7ba3bb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,24 @@ import { init, cleanup } from './whatsapp.js'
import cors from 'cors'

const app = express()
app.use(cors())

const host = process.env.HOST ?? '127.0.0.1'
const onHeroku = process.env.HEROKU ?? false
const host = process.env.HOST || undefined
const port = parseInt(process.env.PORT ?? 8000)

app.use(cors())
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
app.use('/', routes)

if(onHeroku){
app.listen(port, () => {
if(host){
app.listen(port, host, () => {
init()
console.log(`Server is listening on http://${host}:${port}`)
})
}else{
app.listen(port, host, () => {
app.listen(port, () => {
init()
console.log(`Server is listening on http://${host}:${port}`)
console.log(`Server is listening on http://localhost:${port}`)
})
}

Expand Down

0 comments on commit b7ba3bb

Please sign in to comment.