mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
feat: advanced queues (#362)
* feat: advanced queues * feat: advanced queues * feat: advanced queues * feat: advanced queues * update verb specification * add testcase * add testcase * add testcase * updte testcase * fixed * update queue * fix: fix waithook params * fix: fix waithook params * fix: performQueueWebhook with correct members length * fix merge conflict * debug log * debug listen test * debug listen test * debug listen test * debug listen test * debug listen test * debug listen issue * feat: add tts on account level --------- Co-authored-by: Dave Horton <daveh@beachdognet.com>
This commit is contained in:
@@ -2,6 +2,7 @@ const express = require('express');
|
||||
const app = express();
|
||||
const Websocket = require('ws');
|
||||
const listenPort = process.env.HTTP_PORT || 3000;
|
||||
const any_hook_json_mapping = new Map();
|
||||
let json_mapping = new Map();
|
||||
let hook_mapping = new Map();
|
||||
let ws_packet_count = new Map();
|
||||
@@ -61,7 +62,7 @@ app.all('/', (req, res) => {
|
||||
console.log(req.body, 'POST /');
|
||||
const key = req.body.from
|
||||
addRequestToMap(key, req, hook_mapping);
|
||||
return getJsonFromMap(key, req, res);
|
||||
return getJsonFromMap(json_mapping, key, req, res);
|
||||
});
|
||||
|
||||
app.post('/appMapping', (req, res) => {
|
||||
@@ -106,7 +107,7 @@ app.post('/actionHook', (req, res) => {
|
||||
app.all('/customHook', (req, res) => {
|
||||
let key = `${req.body.from}_customHook`;;
|
||||
console.log(req.body, `POST /customHook`);
|
||||
return getJsonFromMap(key, req, res);
|
||||
return getJsonFromMap(json_mapping, key, req, res);
|
||||
});
|
||||
|
||||
app.post('/customHookMapping', (req, res) => {
|
||||
@@ -116,6 +117,23 @@ app.post('/customHookMapping', (req, res) => {
|
||||
return res.sendStatus(200);
|
||||
});
|
||||
|
||||
/**
|
||||
* Any Hook
|
||||
*/
|
||||
|
||||
app.all('/anyHook/:key', (req, res) => {
|
||||
let key = req.params.key;
|
||||
console.log(req.body, `POST /anyHook/${key}`);
|
||||
return getJsonFromMap(any_hook_json_mapping, key, req, res);
|
||||
});
|
||||
|
||||
app.post('/anyHookMapping', (req, res) => {
|
||||
let key = req.body.key;
|
||||
console.log(req.body, `POST /anyHookMapping/${key}`);
|
||||
any_hook_json_mapping.set(key, req.body.data);
|
||||
return res.sendStatus(200);
|
||||
});
|
||||
|
||||
// Fetch Requests
|
||||
app.get('/requests/:key', (req, res) => {
|
||||
let key = req.params.key;
|
||||
@@ -162,9 +180,9 @@ app.get('/ws_metadata/:key', (req, res) => {
|
||||
* private function
|
||||
*/
|
||||
|
||||
function getJsonFromMap(key, req, res) {
|
||||
if (!json_mapping.has(key)) return res.sendStatus(404);
|
||||
const retData = JSON.parse(json_mapping.get(key));
|
||||
function getJsonFromMap(map, key, req, res) {
|
||||
if (!map.has(key)) return res.sendStatus(404);
|
||||
const retData = JSON.parse(map.get(key));
|
||||
console.log(retData, ` Response to ${req.method} ${req.url}`);
|
||||
addRequestToMap(key, req, hook_mapping);
|
||||
return res.json(retData);
|
||||
|
||||
Reference in New Issue
Block a user