boyney123 / mockit

A tool to quickly mock out end points, setup delays and more...
https://mockit.netlify.com/
MIT License
1.58k stars 84 forks source link

improper headers format in mockit-routes/configuration/routes.json #56

Closed monkeyWzr closed 5 years ago

monkeyWzr commented 5 years ago

Hi there @boyney123 First of all, thanks for your brilliant work!

What you did:

cd mockit-routes
npm install
npm run start

Then visit http://localhost:3000/random

What happened:

TypeError: headers.forEach is not a function
    at /mnt/e/git/mockit/mockit-routes/src/index.js:33:15
    at Layer.handle [as handle_request] (/mnt/e/git/mockit/mockit-routes/node_modules/express/lib/router/layer.js:95:5)
    at next (/mnt/e/git/mockit/mockit-routes/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/mnt/e/git/mockit/mockit-routes/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/mnt/e/git/mockit/mockit-routes/node_modules/express/lib/router/layer.js:95:5)
    at /mnt/e/git/mockit/mockit-routes/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/mnt/e/git/mockit/mockit-routes/node_modules/express/lib/router/index.js:335:12)
    at next (/mnt/e/git/mockit/mockit-routes/node_modules/express/lib/router/index.js:275:10)
    at cors (/mnt/e/git/mockit/mockit-routes/node_modules/cors/lib/index.js:188:7)
    at /mnt/e/git/mockit/mockit-routes/node_modules/cors/lib/index.js:224:17

Problem description:

the headers in routes.json should be an array of {header, value} objects as it is in root's routes.json

Suggested solution:

Update mockit-routes/configuration/routes.json

...
"headers": [{
        "header": "x-testing",
        "value": "tester"
      }, {
        "header": "x-testing2",
        "value": "tester2"
      }, {
        "header": "x-testing3",
        "value": "tester3"
      }],
...
boyney123 commented 5 years ago

First of all, thanks for your brilliant work!

Thanks, I'm glad you like it :)

Thanks for raising this issue/bug, I have put a fix in for a release 1.1.1.

57

Thanks again @monkeyWzr