Skip to content

Commit 8c9b395

Browse files
committed
refactor: added port setting into express
1 parent 425f93f commit 8c9b395

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

voice/connect-an-inbound-call.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
require('dotenv').config({ path: __dirname + '/../.env' });
2+
3+
const VONAGE_NUMBER = process.env.VONAGE_NUMBER;
4+
const VONAGE_VIRTUAL_NUMBER = process.env.VONAGE_VIRTUAL_NUMBER;
5+
26
const Express = require('express');
37

48
const app = new Express();
59
const port = process.env.PORT || 3000;
610

7-
const VONAGE_NUMBER = process.env.VONAGE_NUMBER;
8-
const VONAGE_VIRTUAL_NUMBER = process.env.VONAGE_VIRTUAL_NUMBER;
9-
1011
const onInboundCall = (_, response) => {
1112
const ncco = [
1213
{

voice/handle-user-input-dtmf.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
require('dotenv').config({ path: __dirname + '/../.env' });
12
const Express = require('express');
23
const bodyParser = require('body-parser');
34

45
const app = new Express();
6+
const port = process.env.PORT || 3000;
7+
58
app.use(bodyParser.json());
69

710
const onInboundCall = (request, response) => {
@@ -37,4 +40,6 @@ app
3740
.get('/webhooks/answer', onInboundCall)
3841
.post('/webhooks/dtmf', onInput);
3942

40-
app.listen(3000);
43+
app.listen(port, () => {
44+
console.log(`Example app listening on port ${port}`);
45+
});

voice/receive-an-inbound-call.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const Express = require('express');
2+
23
const app = new Express();
4+
const port = process.env.PORT || 3000;
35

46
const onInboundCall = (request, response) => {
57
const from = request.query.from;
@@ -17,4 +19,6 @@ const onInboundCall = (request, response) => {
1719

1820
app.get('/webhooks/answer', onInboundCall);
1921

20-
app.listen(3000);
22+
app.listen(port, () => {
23+
console.log(`Example app listening on port ${port}`);
24+
});

0 commit comments

Comments
 (0)