UNPKG

proxkey

Version:

Proxy/Mock server for testing build on top of HAPI.js

271 lines 8.85 kB
module.exports = { configuration: { host: 'localhost', port: 9091, log: true, dataDir: __dirname }, routes: [ { "request_url": "/a/b", "method": "POST", "params": { "failure": [ { "key": "phone_num", "value": "9876543210" } ], "pattern": [ { "key": "phone_num", "value": "^510" } ], "something": [ { "key": "phone_num", "value": "8888888888" } ], "production": [ { "key": "phone_num", "value": "123432432" } ] }, "response": { "something" :{ "type": "applicaton/xml", "data": "/partners/test/test_some_doc.xml", "code": 200 }, "failure" : { "type": "applicaton/xml", "data": "/partners/test/test_doc.xml", "code": 200 }, "pattern" :{ "type": "application/xml", "data": "/partners/test/test_some_doc.xml", "code": 200, "replace": { "key": "%Change%", "val": "DEFAULT...", "request_key": 'phone_num' } }, "success" : { "type": "application/xml", "data": "/partners/test/test_some_doc.xml", "code": 200, "replace": { "key": "%Change%", "val": "default value", "request_key": 'phone_num' } }, "production": { "host": "httpbin.org", "path": "/post", "port": 80 } } },{ "request_url": "/xml/a", "method": "POST", "params": { "failure": [ { "key": "xmlFirstChild->xmlSecondChild", "value": "9876543210" } ], "something": [ { "key": "xmlFirstChild->xmlSecondChild", "value": "8888888888" } ] }, "response": { "something" :{ "type": "applicaton/json", "data": "{\"data\": \"something\"}", "code": 201 }, "failure" : { "type": "applicaton/json", "data": "{\"data\": \"failure\"}", "code": 401 }, "success" : { "type": "application/xml", "data": "/partners/test/test_some_doc.xml", "code": 200, "replace": { "key": "%Change%", "val": "THIS WILL BE THE DEFUALT STRING TO CHANGE UNLESS THE XML DONT HAVE A VALUE IN THE xmlSecondChild node", "request_key": 'xmlFirstChild->xmlSecondChild' } } } },{ "request_url": "/xml/b", "method": "POST", "params": { "failure": [ { "key": "xmlFirstChild->xmlSecondChild", "value": "9876543210" } ], "something": [ { "key": "xmlFirstChild->xmlSecondChild", "value": "8888888888" } ] }, "response": { "something" :{ "type": "applicaton/json", "data": "{\"data\": \"something\"}", "code": 201 }, "failure" : { "type": "applicaton/json", "data": "{\"data\": \"failure\"}", "code": 401 }, "success" : { "type": "application/xml", "data": "/partners/test/test_some_doc.xml", "code": 200, "replace": { "key": "%Change%", "val": "THIS WILL BE THE DEFUALT STRING TO CHANGE", "request_key": 'xmlFirstChild->xmlSecondChild' } } } },{ "request_url": "/a/c", "method": "POST", "params": { "failure": [ { "key": "phone_num", "value": "9876543210" },{ "key": "phone_num", "value": "123123123" } ] }, "response": { "success" : { "type": "application/json", "data": "/partners/test/test_doc.json", "code": 200 }, "failure" : { "type": "applicaton/xml", "data": "/partners/test/test_doc.xml", "code": 404 } } },{ "request_url": "/say/hi", "method": "POST", "params": { "failure": [ { "key": "name", "value": "ben" } ] }, "response": { "success": { "type": "application/json", "data": "{ hi: 'ben'}", "code": 200 }, "failure": { "type": "application/json", "data": "{ hi: 'Doron' }", "code": 409 } } }, { "request_url": "/test/delay", "method": "POST", "params": { "A": [ { "key": "root->a->b", "value": "AA" } ], "B": [ { "key": "root->a->b", "value": "BB" } ], "C": [ { "key": "root->a->b", "value": "CC" } ], "D": [ { "key": "root->a->b", "value": "DD" } ] }, "response": { "A" :{ "type": "applicaton/json", "data": "{\"data\": \"AAAAAAAAA\"}", "code": 200, "delay": function() { return 1000; } }, "B" : { "type": "applicaton/json", "data": "{\"data\": \"BBBBBBBBB\"}", "code": 200, "delay": 1000 }, "C" : { "type": "applicaton/json", "data": "{\"data\": \"CCCCCCCCCCCCCCCC\"}", "code": 200, "delay": '1000' }, "D" : { "type": "applicaton/json", "data": "{\"data\": \"DDDDDDDDDDD\"}", "code": 200, "delay": null }, "success" : { "type": "application/xml", "data": "{\"data\": \"SUCESSSSS\"}", "code": 200, "replace": { "key": "%Change%", "val": "THIS WILL BE THE DEFUALT STRING TO CHANGE", "request_key": 'xmlFirstChild->xmlSecondChild' } } } } ] };