Skip to content

Commit a4016f5

Browse files
committed
refactor: adjusted variable settings for express
1 parent 8c9b395 commit a4016f5

12 files changed

+41
-22
lines changed

voice/answer-webhook-endpoint.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
require('dotenv').config({ path: __dirname + '/../.env' });
2+
3+
const port = process.env.PORT || 3000;
4+
25
const Express = require('express');
36
const bodyParser = require('body-parser');
47

58
const app = new Express();
6-
const port = process.env.PORT || 3000;
79

810
app.use(bodyParser.urlencoded({ extended: false }));
911

voice/conference-call.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
require('dotenv').config({ path: __dirname + '/../.env' });
2+
3+
const VOICE_CONF_NAME = process.env.VOICE_CONF_NAME;
4+
const port = process.env.PORT || 3000;
5+
26
const Express = require('express');
37
const bodyParser = require('body-parser');
48

59
const app = new Express();
6-
const port = process.env.PORT || 3000;
710
app.use(bodyParser.json());
811

9-
const VOICE_CONF_NAME = process.env.VOICE_CONF_NAME;
10-
1112
const onInboundCall = (_, response) => {
1213
const ncco = [
1314
{

voice/connect-an-inbound-call.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ require('dotenv').config({ path: __dirname + '/../.env' });
22

33
const VONAGE_NUMBER = process.env.VONAGE_NUMBER;
44
const VONAGE_VIRTUAL_NUMBER = process.env.VONAGE_VIRTUAL_NUMBER;
5+
const port = process.env.PORT || 3000;
56

67
const Express = require('express');
78

89
const app = new Express();
9-
const port = process.env.PORT || 3000;
1010

1111
const onInboundCall = (_, response) => {
1212
const ncco = [

voice/connect-synchronous.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
require('dotenv').config({ path: __dirname + '/../.env' });
2+
3+
const port = process.env.PORT || 3000;
4+
const VONAGE_VIRTUAL_NUMBER = process.env.VONAGE_VIRTUAL_NUMBER;
5+
const VOICE_TO_NUMBER = process.env.VOICE_TO_NUMBER;
6+
27
const Express = require('express');
38
const bodyParser = require('body-parser');
49

510
const app = new Express();
611
app.use(bodyParser.json());
712

8-
const port = process.env.PORT || 3000;
9-
const VONAGE_VIRTUAL_NUMBER = process.env.VONAGE_VIRTUAL_NUMBER;
10-
const VOICE_TO_NUMBER = process.env.VOICE_TO_NUMBER;
1113

1214
app.get('/answer', (req, res) => {
1315
const serverHost = req.protocol + '://' + req.host;

voice/handle-user-input-asr.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
require('dotenv').config({ path: __dirname + '/../.env' });
2+
3+
const port = process.env.PORT || 3000;
4+
25
const Express = require('express');
36

47
const app = new Express();
5-
const port = process.env.PORT || 3000;
68

79
const onInboundCall = (request, response) => {
810
const ncco = [

voice/handle-user-input-dtmf.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
require('dotenv').config({ path: __dirname + '/../.env' });
2+
3+
const port = process.env.PORT || 3000;
4+
25
const Express = require('express');
36
const bodyParser = require('body-parser');
47

58
const app = new Express();
6-
const port = process.env.PORT || 3000;
79

810
app.use(bodyParser.json());
911

voice/receive-an-inbound-call.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
require('dotenv').config({ path: __dirname + '/../.env' });
2+
3+
const port = process.env.PORT || 3000;
4+
15
const Express = require('express');
26

37
const app = new Express();
4-
const port = process.env.PORT || 3000;
58

69
const onInboundCall = (request, response) => {
710
const from = request.query.from;

voice/record-a-call-with-split-audio.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
require('dotenv').config({ path: __dirname + '/../.env' });
2-
const Express = require('express');
3-
const bodyParser = require('body-parser');
42

53
const VOICE_TO_NUMBER = process.env.VOICE_TO_NUMBER;
64
const VONAGE_VIRTUAL_NUMBER = process.env.VONAGE_VIRTUAL_NUMBER;
75
const port = process.env.PORT || 3000;
86

7+
const Express = require('express');
8+
const bodyParser = require('body-parser');
9+
910
const app = new Express();
1011
app.use(bodyParser.json());
1112

voice/record-a-call.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
require('dotenv').config({ path: __dirname + '/../.env' });
2-
const Express = require('express');
3-
const bodyParser = require('body-parser');
42

53
const VOICE_TO_NUMBER = process.env.VOICE_TO_NUMBER;
64
const VONAGE_VIRTUAL_NUMBER = process.env.VONAGE_VIRTUAL_NUMBER;
75
const port = process.env.PORT || 3000;
86

7+
const Express = require('express');
8+
const bodyParser = require('body-parser');
9+
910
const app = new Express();
1011
app.use(bodyParser.json());
1112

voice/record-a-conversation.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
require('dotenv').config({ path: __dirname + '/../.env' });
2-
const Express = require('express');
3-
const bodyParser = require('body-parser');
42

53
const VOICE_CONF_NAME = process.env.CONF_NAME;
64
const port = process.env.PORT || 3000;
75

6+
const Express = require('express');
7+
const bodyParser = require('body-parser');
8+
89
const app = new Express();
910
app.use(bodyParser.json());
1011

@@ -14,7 +15,7 @@ const onInboundCall = (request, response) => {
1415
'action': 'conversation',
1516
'name': VOICE_CONF_NAME,
1617
'record': 'true',
17-
'eventMethod': 'POST', // This currently needs to be set rather than default due to a known issue https://help.nexmo.com/hc/en-us/articles/360001162687
18+
'eventMethod': 'POST',
1819
'eventUrl': [`${request.protocol}://${request.get('host')}/webhooks/recordings`],
1920
},
2021
];

voice/record-a-message.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
const Express = require('express');
2-
const bodyParser = require('body-parser');
1+
require('dotenv').config({ path: __dirname + '/../.env' });
32

43
const port = process.env.PORT || 3000;
54

5+
const Express = require('express');
6+
const bodyParser = require('body-parser');
7+
68
const app = new Express();
79
app.use(bodyParser.json());
810

voice/track-ncco-progress.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
const Express = require('express');
2-
const app = new Express();
1+
require('dotenv').config({ path: __dirname + '/../.env' });
32

43
const port = process.env.PORT || 3000;
54

5+
const Express = require('express');
6+
const app = new Express();
7+
68
const onInboundCall = (request, response) => {
79
const ncco = [
810
{

0 commit comments

Comments
 (0)