mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
feat: play verb url support single or array list url (#158)
* feat: update time-series 0.11.12 * feat: support play verb url in plain text or array * fix: review comment Co-authored-by: Dave Horton <daveh@beachdognet.com>
This commit is contained in:
@@ -20,11 +20,7 @@ app.use(express.json());
|
||||
app.all('/', (req, res) => {
|
||||
console.log(req.body, 'POST /');
|
||||
const key = req.body.from
|
||||
if (!json_mapping.has(key)) return res.sendStatus(404);
|
||||
const retData = JSON.parse(json_mapping.get(key));
|
||||
console.log(retData, `${req.method} /`);
|
||||
addRequestToMap(key, req, hook_mapping);
|
||||
return res.json(retData);
|
||||
return getJsonFromMap(key, req, res);
|
||||
});
|
||||
|
||||
app.post('/appMapping', (req, res) => {
|
||||
@@ -52,6 +48,24 @@ app.post('/actionHook', (req, res) => {
|
||||
return res.sendStatus(200);
|
||||
});
|
||||
|
||||
/*
|
||||
* customHook
|
||||
* For the hook to return
|
||||
*/
|
||||
|
||||
app.all('/customHook', (req, res) => {
|
||||
let key = `${req.body.from}_customHook`;;
|
||||
console.log(req.body, `POST /customHook`);
|
||||
return getJsonFromMap(key, req, res);
|
||||
});
|
||||
|
||||
app.post('/customHookMapping', (req, res) => {
|
||||
let key = `${req.body.from}_customHook`;
|
||||
console.log(req.body, `POST /customHookMapping`);
|
||||
json_mapping.set(key, req.body.data);
|
||||
return res.sendStatus(200);
|
||||
});
|
||||
|
||||
// Fetch Requests
|
||||
app.get('/requests/:key', (req, res) => {
|
||||
let key = req.params.key;
|
||||
@@ -77,6 +91,14 @@ app.get('/lastRequest/: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));
|
||||
console.log(retData, ` Response to ${req.method} ${req.url}`);
|
||||
addRequestToMap(key, req, hook_mapping);
|
||||
return res.json(retData);
|
||||
}
|
||||
|
||||
function addRequestToMap(key, req, map) {
|
||||
let headers = new Map()
|
||||
for(let i = 0; i < req.rawHeaders.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user