|
|
|
@ -18,14 +18,13 @@ const aclPaths = {
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const app = express();
|
|
|
|
|
app.use(express.json());
|
|
|
|
|
|
|
|
|
|
const vonageNumber = "12052553394"; //用于通话的号码,今后根据前端提交来做号码切换
|
|
|
|
|
|
|
|
|
|
//设置跨域访问
|
|
|
|
|
app.all('*', function(req, res, next) {
|
|
|
|
|
app.all("*", function (req, res, next) {
|
|
|
|
|
res.header("Access-Control-Allow-Origin", "*");
|
|
|
|
|
res.header("Access-Control-Allow-Headers", "*");
|
|
|
|
|
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
|
|
|
|
@ -42,6 +41,10 @@ app.get("/voice/answer", (req, res) => {
|
|
|
|
|
action: "talk",
|
|
|
|
|
text: "Please wait while we connect you.",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
action: "record",
|
|
|
|
|
eventUrl: [`${req.protocol}://${req.get("host")}/vonage-server/voice/recordings`],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
action: "connect",
|
|
|
|
|
from: vonageNumber,
|
|
|
|
@ -57,7 +60,7 @@ app.get("/jwt", (req, res) => {
|
|
|
|
|
exp: Math.round(exp_time.getTime() / 1000),
|
|
|
|
|
sub: "hainatravel",
|
|
|
|
|
acl: aclPaths,
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
console.log(Math.round(exp_time.getTime() / 1000));
|
|
|
|
|
console.log(token);
|
|
|
|
|
console.log("---");
|
|
|
|
@ -82,5 +85,10 @@ app.all("/voice/fallback", (req, res) => {
|
|
|
|
|
res.sendStatus(200);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.all("/voice/recordings", (req, res) => {
|
|
|
|
|
console.log("recordings:");
|
|
|
|
|
console.dir(req.body);
|
|
|
|
|
res.sendStatus(200);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.listen(3009);
|
|
|
|
|