-
Notifications
You must be signed in to change notification settings - Fork 38
/
index.js
executable file
·62 lines (48 loc) · 1.51 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require('dotenv').load();
const http = require('http');
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser')
const methods = require('./src/server.js');
const tokenGenerator = methods.tokenGenerator;
const makeCall = methods.makeCall;
const placeCall = methods.placeCall;
const incoming = methods.incoming;
const welcome = methods.welcome;
var twilio = require('twilio');
// Create Express webapp
const app = express();
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
app.get('/', function(request, response) {
response.send(welcome());
});
app.post('/', function(request, response) {
response.send(welcome());
});
app.get('/accessToken', function(request, response) {
tokenGenerator(request, response);
});
app.post('/accessToken', function(request, response) {
tokenGenerator(request, response);
});
app.get('/makeCall', function(request, response) {
makeCall(request, response);
});
app.post('/makeCall', function(request, response) {
makeCall(request, response);
});
app.get('/placeCall', placeCall);
app.post('/placeCall', placeCall);
app.get('/incoming', function(request, response) {
response.send(incoming());
});
app.post('/incoming', function(request, response) {
response.send(incoming());
});
// Create an http server and run it
const server = http.createServer(app);
const port = process.env.PORT || 3000;
server.listen(port, function() {
console.log('Express server running on *:' + port);
});