Giter VIP home page Giter VIP logo

apimocker's People

Contributors

abhijeetahuja avatar aburmeis avatar aleofreddi avatar asnov avatar dependabot[bot] avatar dmeenhuis avatar dploeger avatar ebasilecimpress avatar enhan avatar ferrerod avatar gstroup avatar igutsaliuk avatar ivank avatar jcstover avatar jimihford avatar kopach avatar pawel-mika avatar pgraham avatar pgraham-acn avatar renovate-bot avatar samurai336 avatar stelio avatar thejonan avatar thomaslomas avatar twalker avatar wprater avatar ztsmith avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apimocker's Issues

Handle multiple query parameters

I have the requirement to handle multiple query parameters and send switch responses based on that. For example: my client would trigger the URL as "{host-name}/management/v1/organizations/org/oauth2/revoke?enduser=abcd&app=efgh". How should the mocker resource in api mocker should look like ?
Currently, the documentation does not specify any implicit way to handle this requirement. Can you please confirm if we can handle this scenario ?

Optional or wildcard switch values

It would be great if there was a way to ignore values that are not important.
One possibility would be to use some kind of wildcard.

e.g. config setup with:
"switch": [ "Foo", "Bar" ],
"mockFile": "data.json"

A request URL of:
/example?Foo=1&Bar=2

Would match the files:
Foo1Bar2.data.json
FooBar2.data.json
Foo1Bar
.json

Where '*' is a wildcard matching any value.
The wildcard would likely need to be some kind of token to avoid filename issues:
e.g. Foo_any_Bar_any_

Another approach would be to make switch parameters optional. Effectively making any skipped parameter a wildcard.

The same request URL would match:
Bar2.data.json
Foo1.data.json

Looking at the code, this would require the setSwitchOptions function to return a collection of switch parameters and values. This would allow different (ordered) permutations of mock file loading to be tried.

Any thoughts? Would this be a major breaking change for some people?
If this sounds reasonable and I can find some time, I could put a PR together.

Easy way to display images?

Hi Greg,

here is another interesting question:

As first! I like your api mocker very much. It is very easy to use and it makes fun! Great work!

But I've got a problem with simple files. I created a file structure with a folder called "images". The folder is full of '.jpgs' Images maybe more than 60. I don't want to define every single image with a mock-path. Is there a possibility to call them all like:

"images/events/*.jpg": {
      "mockFile": "images/events/*.jpg",
      "verbs": ["get"]
    },

So, that I can call them with their name (e.g 21442.jpg) and the path mentioned above?
Im looking forward for your help!

Kind regards,
Kevin

How to mock 'Content-Type: application/soap+xml' requests?

Hello Guys!
I am trying to mock some soap xml API but I stucked with the problem that API receives gzip-ed request only So I have to send gzip-ed request from my app.
The question is how I can receive a gzip-ed request by apimock?
I have the next config for apimock: IIS + iisnode + node.js + apimock (using regexp type switchs to parse xml). Requests are gzip-ed xml files.
Thank you!

Switches aren't working for :id on get

Hi,
I want to do a simple switch based on and id for example:

"dogs/:id" { 
 "mockFile": "dogs/dog.json"
"verbs": [ "get"],
"switch": "id"
}

but it wont pick up dog1.dog.json with a request like:

GET /dogs/dog1

if I have it in the dogs directory. Thoughts? This is on the latest.

Switch by json key

I have the following request structure (all requests POST to /):

AuthRequest:

{
  "Header": {...},
  "Body": {
    "AuthRequest": { <Parameters for Auth Request> }
  }
}

GetMailboxRequest:

{
  "Header": {...},
  "Body": {
    "GetMailboxRequest": { <Parameters for GetMailbox Request> }
  }
}

I'd have to deliver two mocks. One for the AuthRequest and one for the GetMailboxRequest.

So I need to switch by the first key of "Body"? Is this possible? I don't see how I can configure this. JsonPath doesn't seem to work for this specific task.

Provide support for optional basepath in URL

I would like to be able to specify a "basepath" which is basically a prefix on webservices.

That helps me to use apimocker locally and in my Apigee API proxy, which specifies its own "basepath".

GET http://localhost:4000/basepath/customers

Then I can just change the value of basepath to "" when I deploy into Apigee
GET http://api-gateway:9000/basepath/customers

This can be done with express pretty straightforward.

apiMocker.express.use(options.basePath,apiMocker.router);

support 404 by missing default mockFile

How to configure a mock that only returns a resource where the file is present for the switch but returns 404 otherwise? I would expect if I configure a mockFile test.json and have a switch id I would get id42.test.json contents if exists or 404 if test.json does not exists.

Even better would be to have an option to set the status for a missing mock file for a switch.

configuring different types of HTTP status codes for routes

Hi @gstroup,

First to all, excellent tool you have here.

I have a suggestion for adding an improvement. It would be great if I can configure for certain routes that they return an specific HTTP status code rather than 200. For instance, I need to mock up a server which exposes a API with a DELETE verb. In this particular case, the only thing the server will respond is 204 HTTP status code (no body at all) to confirm that the removal I asked for worked fine. Unfortunately I cannot do this with the current code of apimocker.

Makes sense?

Thx in advance.

How to make multiple verbs in the same url return different files?

Hello, I am trying to mock a get/post using something like this:

"webServices": {
"user/:userId": {
"latency": 700,
"verbs": ["get", "post"],
"responses": {
"get": {
"mockFile": "user.json"
},
"post": {
"mockFile": "user_save.json"
}
}
},
...

But I am receiving the following warning from grunt:

WARNING: apimocker config file format is deprecated.
Warning: undefined is not a function Use --force to continue.

Aborted due to warnings.

It only happens when I try using the "responses" object, if I remove it and use a single "mockFile" it works fine.

credentials

can't find how to add access-control-allow-credentials to header response

Proxy post request hangs

With proxy request, posting with body hangs. You have to push bodyParser after proxy, this will fix the issue

How to set paths in cloud foundry ?

I ma newbie and trying ti install server in cloud foundry. I have few questions

  • How to specify mockdirectory or static directory in CF world as there is no persistence available ?

Unable to proxy request to https enpoint with selfsigned certificate

Certificate is valid for *.ab*.net
I'm trying to get data from path.abexample.net
As the result I'm getting:

Error: self signed certificate
    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:1065:38)
    at emitNone (events.js:80:13)
    at TLSSocket.emit (events.js:179:7)
    at TLSSocket._init.ssl.onclienthello.ssl.oncertcb.TLSSocket._finishInit (_tls_wrap.js:593:8)
    at TLSWrap.ssl.onclienthello.ssl.oncertcb.ssl.onnewsession.ssl.onhandshakedone (_tls_wrap.js:425:38)

Any chances for switch to ignore that kind of errors?

Is it possible to dump or list all expecations?

Clearly, the configuration is the starting point of the service.
However, since it's possible to create more expectations using the admin API, is it also possible to dump or reflect the in-memory configuration of the server, so that the next time we could have all configuration in a file?

Add proxy option

It would be great to have a function that allows any non-configured webservice endpoints to be forwarded to a proxy.

A possible use case might be if you only want to partially mock an API, and forward all non-mocked endpoints to the real API.

This looks relatively straight forward to implement, and I would be happy to submit a PR if there is interest.

One implementation question I have is - should we forward only for endpoints that are not configured, or also include endpoints where no switch value is matched?

Method PATCH is not allowed by Access-Control-Allow-Methods in preflight response

Hi,

We are facing an issue - XMLHttpRequest cannot load http://localhost:7879/myApp/myService/v1/account. Method PATCH is not allowed by Access-Control-Allow-Methods in preflight response.

I tried adding CORS module and also tried adding response headers in my mock server but it didn't work, later found that adding the PATCH in apimaker.js resolved the issue.

node_modules\apimocker\lib\apimocker.js should have res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,PATCH,DELETE'); instead res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');

Is there specific reason for not supporting PATCH ? without PATCH it works fine from postman but not working from our application.

It would be great if this could be resolved.

thanks,
Ashish Pashap

Json coming in Request Parameter

Is the JSON coming in Request Parameter supported ?
like :

responseJSON= {
"customerId" : "12";
"city" : "Cincinnati"

}

can you use a switch statement on the request parameter : responseJSON and then parse it for customerId or city or both ?

Thanks

Not start apimocker -p -8081 -c config.json

Hi!
After update 0.3.3 my mock not working.
What's the problem?

config.json

{
    "note": "",
    "mockDirectory": "./api",
    "staticDirectory": "./static",
    "staticPath": "/",
    "quiet": false,
    "allowedDomains": ["*"],
    "allowedHeaders": ["access-control-allow-origin", "accept", "access-control-allow-headers", "access-control-allow-methods"],
    "latency": 0,

    "webServices": {
        "api/account/userinfo": {
            "httpStatus": 401,
            "mockFile": "200.json",
            "verbs": ["get"]
        },
        "api/account/logout": {
            "verbs": ["post"],
            "httpStatus": 200,
            "mockFile": "200.json"
        }
    }
}

c:\Code\apimocker>apimocker -p -8081 -c config.json

Loading config file: c:\Code\apimocker\config.json
Set route: GET api/account/userinfo : 200.json
Set route: POST api/account/logout : 200.json
Mock server listening on port -8081

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EACCES
    at errnoException (net.js:904:11)
    at Server._listen2 (net.js:1023:19)
    at listen (net.js:1064:10)
    at Server.listen (net.js:1132:5)
    at Function.app.listen (C:\Users\DRyltsov\AppData\Roaming\npm\node_modules\apimocker\node_module
s\express\lib\application.js:525:24)
    at Object.apiMocker.start (C:\Users\DRyltsov\AppData\Roaming\npm\node_modules\apimocker\lib\apim
ocker.js:272:49)
    at Object.<anonymous> (C:\Users\DRyltsov\AppData\Roaming\npm\node_modules\apimocker\bin\apimocke
r.js:19:6)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

Mock url only if parameter contains variable

Hi,

I have a usecase where i want urls to be mocked only if they contain certain parameters, and else they should not deliver a mock, they should point to the real endpoint.

something like this:
"var/:id": { "mockFile": "xml/queen.xml", "verbs": ["all"], "switch": "id" }

but with the combination that the default points to the real endpoint and if there is a mock file with the correct switch value than this should be delivered.

Could you please think about implementing this ?
With regards,
Fabian

POST parameters (switch?) available for template feature?

I would like to use the values of parameters in a JSON POST body and substitute them into a JSON template file that I will return as a response to this request. Is this possible? How would I accomplish this? Do I need to use a smart JSON-Path based switch statement to identify the parameters and then use the template naming convention within the response .json file? The current simplistic template example shows the templated parameters in the GET request query string, while I would like to use the my POST parameters.

Request params

Is it possible to deal with request params with apimocker? I'd like to handle the request e.g. /api/resource?page=1 and /api/resource?page=2 and so on.

Should resolve ~ in path to home directory

If mockDirectory in config.json starts with '~', e.g. "mockDirectory": "~/some/path/", it should resolve the tilde to the current user's home directory.

E.g. if config.json looks like:

{
  "mockDirectory": "~/some/path/",
  "quiet": false,
  "port": "1234",
  "latency": 50,
  "allowedDomains": ["abc.com"],
  "allowedHeaders": ["Content-Type", "my-custom-header"],
  "webServices": {
    "a/b/c": {
      "mockFile": "some_file.json",
      "latency": 20,
      "verbs": ["get"]
    }
  }
}

And in ~/some/path/some_file.json you have:

{
  "this": "worked"
}

If you start apimocker and try to GET that provided service, it has an error, e.g.: Error: ENOENT, stat &#39;~/some/path/some_file.json&#39;.

A workaround is to modify the config prior to use to replace ~ in the mockDirectory value of config.json with the home directory path, e.g.:

mkdir -p tmp/apimock
sed 's#~#'$HOME'#g' config.json > tmp/apimock/config.json
apimocker -c tmp/apimock/config.json

No License

This looks like a great project, but with no license information in the project I unfortunately can't use it in my environment.

Is it possible to negate value in switchResponses part of config.json?

Let's assume the code:

"switch": ["name", "age"],
"responses": {
  "post": {"mockFile": "default.json"}
},
"switchResponses": {
  "nameJohnage[NOT]20": {"mockFile": "John.json"},
  "nameJohnage20": {"mockFile": "John20.json"}
}

I expect that providing parameters name=John and age=99 would give a response from anyOtherJohn.json

I also thought about skipping the second parameter:

"switch": ["name", "age"],
"responses": {
  "post": {"mockFile": "default.json"}
},
"switchResponses": {
  "nameJohn": {"mockFile": "John.json"},
  "nameJohnage20": {"mockFile": "John20.json"}
}

But, by the documentation apimocker will look for the filename that matches ALL the request parameters. If one does not match, then the base file will be returned. So I guess I would get default.json instead of John.json for parameters name=John and age=99.
And I'm not sure what I would get for name=John and age=20

Please advice.

Issue with switches

Hi Greg,

I have defined a switch for my event.json.

"app/events/event_detail": {
"mockFile": "events/event.json",
"verbs": ["get"],
"switch": "event_id"
},

My case:

If I call the url "http://localhost:8888/app/events/event_detail?event_id=test"
and I have no specific json file created: the browser outputs me the "event.json". Everything is fine until here.

But is there a possibility to out put another "summertime.json" File when I call the URL "http://localhost:8888/app/events/event_detail" than the base file "event.json"?

What I want to do?

I want to handle error codes. So if I want to get back different ".json" files when I call:
"http://localhost:8888/app/events/event_detail?event_id=test" ( if not exist should return base file) AND
"http://localhost:8888/app/events/event_detail" (should not return the base file like in the case before)

I hope you can help me!

Cheers

POST- Body regex support

Sers,

a common use case for e.g. POST, PUT is to have e.g. json in the request body.
Within the request, an ID is given, which I want to return a concrete response to.

A simple regex would be enough, I think.

How do you think about such an improvement?

'$' sign in URL is not working

Hi,

My service URL is like "abc/flights/$/incoming" and I am unable to mock this URL. Also there is no error in console.

Any workaround or solution.

Regards,

Jawwad

Support Parse Server mocking.

Hi there.

Would be nice if this would also support Parse Server mocking.

The reason why it doesn't right now is that Parse Server avoids pre-flight requests by always sending a Content-Type of text/plain on the request headers.
Using that kind of Content-Type for requests that have the parameters inside the body as json makes the switch feature of apimocker useless - since that is not parsed in the current version with body-parser.
I would like to propose to add another middleware that will look something like this:

apiMocker.middlewares.push(bodyParser.json({
		strict: false,
		verify: saveBody,
		type: 'text/plain'
	}));

I will add it myself and make a PR but want to know how you feel about this.

Incorrect documentation around templating

Hey! Really great tool. We depend on this heavily here at Citi for our mobile apps.

Just wanted to call out an issue we had that unfortunately was caused by incorrect documentation here in your 'readme.md' file. Specifically, it's around templating.

In your example, you stated that for this configuration...

 "template/:Name/:Number" :{
   "mockFile": "templateSample.json",
   "verbs":["get"],
   "enableTemplate": true
   "contentType":"application/json"
 }

With this template...

{
  "Name": "@Name",
  "Number": "@Number"
}

When you call /John/12345 you claim it will return this:

{
	"Name": "John"
	"Number": 12345
}

But we're actually getting this...

{
	"Name": "John"
	"Number": "12345"  <-- Note the quotes
}

For one of our service calls, we needed the non-quote-wrapped number.

The confusion came in when we opened up our template in a JSON editor and tried removing the quotes around '@Number' but it started barking at us that we now had invalid JSON, so thinking that wasn't the correct approach, we abandoned it.

The problem is that actually is the correct way to format the template to have it return the placeholder without quotes. It just means that your template pre-filled-in is not valid JSON, and thus has to be edited with a text file. That's what tripped us up.

If you put a note/caveat/warning/whatever stating that if you need the non-quoted version, your template will no longer be valid JSON, but is still valid for Mocker (since it will become valid once merged) it would've gone a long way to helping people like us avoiding going down a rabbit hole trying to debug something we didn't actually have to debug.

That said, have you considered doing something like this for the tokens you don't want to have to wrap?

"#Number" or
"@@Number" or
"@Number@"
etc...

By implementing something like that (I'm personally partial to the '@@' myself) we can still keep our templates editable with a JSON editor without sacrificing output which is essential considering we run validation scripts against our JSON response files and now we have to explicitly exclude one.

It shouldn't be too difficult to implement with RegEx either. Just search for that version first, consuming the quotes as part of the search, then run the parsing again with the second flavor just as you do now. (You may even be able to format a single RegEx that handles both!)

Anyway, hope this helps. Again, keep up the really, really great work!

Mark

Make `switch` option more useful

I suppose this is more of a general question about the usefulness of the switch option for a specific service configuration.

Let's take this example:

    "users/:userId": {
      "mockFile": "users/users.json",
      "verbs": ["get", "put"],
      "switch": "userId",
      "responses": {
        "put": {"httpStatus": 200, "mockFile": "users/updated.user.josn"}
      }
    }

Wouldn't it be great if what switch did was to look inside the specified mockFile of users/users.json, iterate the array to find where the value of the userId property matched the userId parameter sent in the request, then returned that single user object out of the array of users?

From what I can tell looking at apimocker's source, this is totally possible. If you think its a decent idea, I'd be more than willing to make a PR.

Thoughts?

Sample with SOAP request and swich SOAP response

Hi,

I can not find an example where the SOAP response change depending on what the SOAP request sent.
For example, if I send

<code>es</code>

I need receive (countryEs.xml)
<country>Spain</country>

and if I send
<code>fr</code>

I need receive (countryFr.xml)
<country>France</country>

could you help me with config.json?

Thank You!!!

204 response prevent any switchResponses to be executed

Take this simple endpoint config example:

"cards/updatePin": {
      "verbs": ["post"],
      "switch": ["notfound", "unauthorised"],
      "responses":{
        "post": {
            "httpStatus": 204
        }
      },
      "switchResponses": {
        "notfoundtrue": {"httpStatus": 404, "mockFile": "notfound.json"},
        "unauthorisedtrue": {"httpStatus": 403, "mockFile": "unauthorised.json"}
      }
    }

make a post request to cards/updatePin?notfound=true or cards/updatePin?unauthorised=true

EXPECTED result:

a 404 or 403 response is returned with payload defined in notfound.json or unauthorised.json

ACTUAL result:
204 code is always returned

Windows cannot switch parameters

Switch values can also be passed in as query parameters: http://localhost:7878/nested/ace?customerId=1234 or as part of the URL, if you have configured your service to handle variables, like the "var/:id" service above: http://localhost:7878/var/789 If the specific file, such as "customerId1234.ace.json" is not found, then apimocker will attempt to return the base file: "ace.json".

If the mockfile is set to api\\test\\get.json of endpoint api/:test and the user uses Windows and access api/foo it will return testfoo.api\test\get.json instead of api\test\testfoo.get.json.

Dynamic content in response

Suppose I want dynamic content in reponse json/xml, like time-stamp, random number, uuid, then there should be some provision with enableTemplate feature to serve dynamic content if we annotate our json/xml like:
<queen> <suit>@name</suit> <time>@timestamp</time> <setup>@uuid</setup> </queen>

different content-type values for different responses

It would be great if we could specify different headers for different responses. For example, I would like to return either a file or a json string, depending on the Accept header in the request.

I can use "switch" to send back a different response based on the Accept Header, but there doesn't seem to be any way to set the response headers (e.g. content-type, etc.) per response.

accept callback function for user requests as a parameter for apimock

Hi @gstroup ,

I use apimock like this:

var ApiMocker = require("apimocker");
var apiMocker = ApiMocker.createServer(options)
    .setConfigFile(__dirname + '/config.json')
    .start(port, function() {/* callback for establish connection */});

Now I faced the task to use TimeStamp in responses because of the strict security restrictions of the .Net WCF library.

Is it possible to add response callback function to apimock?

server shutdown when request data is invalid

Please see my log output. if the request data is invalid, the server will be shutdown.
I am working on window, i am not sure if linux have the sample probleam

C:\Users\pauldeng>apimocker
Loading config file: C:\Users\pauldeng\AppData\Roaming\npm\node_modules\apimocker\config.json
Set route: GET first : king.json 20 ms
Set route: POST first : ace.json 20 ms
Set route: DELETE second : 50 ms
Set route: POST second : king.json 50 ms
Set route: POST nested/ace : ace.json 50 ms
with switch on param: customerId
Set route: GET nested/ace : ace.json 50 ms
with switch on param: customerId
Set route: POST nested/ace2 : ace.json 50 ms
with switch on param: [ 'customerId', 'multitest' ]
Set route: GET nested/ace2 : ace.json 50 ms
with switch on param: [ 'customerId', 'multitest' ]
Set route: ALL var/:id/:color : xml/queen.xml 50 ms
with switch on param: [ 'id', 'color' ]
Set route: POST login : sorry.json 50 ms
with switch on param: [ 'userId', 'password' ]
Set route: GET template/:name/:number : templateSample.json 50 ms
Set route: GET templateSwitchGetParams : templateSwitchSample.json 50 ms
Set route: POST templateSwitchPostJsonPath : templateSwitchSample.json 50 ms
Mock server listening on port 7878
Returning mock: GET first : king.json
templateSwitch[appID] value NOT FOUND
templateSwitch[appName] value NOT FOUND
templateSwitch[userName] value NOT FOUND
templateSwitch[userAge] value NOT FOUND
Returning mock: GET templateSwitchGetParams : templateSwitchSample.json
C:\Users\pauldeng\AppData\Roaming\npm\node_modules\apimocker\lib\apimocker.js:190
key = switches[s].key;
^

TypeError: Cannot read property 'key' of undefined
at C:\Users\pauldeng\AppData\Roaming\npm\node_modules\apimocker\lib\apimocker.js:190:24
at Array.forEach (native)
at Object.apiMocker.fillTemplateSwitch (C:\Users\pauldeng\AppData\Roaming\npm\node_modules\apimocker\lib\apimocker.js:186:12)
at C:\Users\pauldeng\AppData\Roaming\npm\node_modules\apimocker\lib\apimocker.js:268:28
at FSReqWrap.readFileAfterClose as oncomplete
C:\Users\pauldeng>

Cannot send empty body for default response

I cannot set a default response that only has httpStatus and no body:

"responses": {
"post": {"httpStatus": 401 }
}

I get the following error

/Users/myuser/Projects//mock-api/apiproxy/resources/node/node_modules/apimocker/lib/apimocker.js:394
mockFileParts = options.mockFile.split("/");
^

TypeError: Cannot read property 'split' of undefined
at Object.apiMocker.setSwitchOptions (/Users/miren/Projects/mock-api/apiproxy/resources/node/node_modules/myuser/lib/apimocker.js:394:35)
at Timeout._onTimeout (/Users/myuser/Projects/mock-api/apiproxy/resources/node/node_modules/apimocker/lib/apimocker.js:231:17)
at tryOnTimeout (timers.js:224:11)
at Timer.listOnTimeout (timers.js:198:5)

Apimocker crashes when mockFile is missing

Apimocker (v.0.4.0) crashes when required element mockFile is missing for webservice:

{
    "mockDirectory": "/home/me/apimocker",
    "quiet": false,
    "port": "8300",
    "webServices": {
        "items/1": {
            "verbs": ["get"]
        }
    }
}
$ apimocker -c config.json
Loading config file: /home/me/apimocker/config.json
Set route: GET items/1 : <no mockFile> 
Mock server listening on port 8300
curl -v localhost:8300/items/1                                                                                                                    โŽ
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8300 (#0)
> GET /items/1 HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:8300
> Accept: */*
> 
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
path.js:360
        throw new TypeError('Arguments to path.join must be strings');
              ^
TypeError: Arguments to path.join must be strings
    at path.js:360:15
    at Array.filter (native)
    at Object.exports.join (path.js:358:36)
    at null._onTimeout (/usr/lib/node_modules/apimocker/lib/apimocker.js:151:21)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

Maybe it should return 5xx server error HTTP status code insted?

Hide <pre> Tags in DOM

Hi Greg,

how can I easily turn off that you node parses JSON into the < pre > Tags automatically?
Thank you for your help!

Is it also possible to output an empty DOM?

Specify status code based on request/form parameter

Is there a way to specify a http status code based on a request/form parameter? For example if I have a rest api mock for authentication I wanna return 401 by default but in case they submit the password parameter with password it should return 200

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.