{"id":1259,"date":"2023-01-28T00:54:00","date_gmt":"2023-01-27T21:24:00","guid":{"rendered":"https:\/\/m-shaeri.ir\/blog\/?p=1259"},"modified":"2024-10-22T20:26:19","modified_gmt":"2024-10-22T16:56:19","slug":"mockimouse-an-easy-to-use-mock-server-to-build-fake-dynamic-api","status":"publish","type":"post","link":"https:\/\/mshaeri.com\/blog\/mockimouse-an-easy-to-use-mock-server-to-build-fake-dynamic-api\/","title":{"rendered":"MockiMouse, Easy To Use Mock Server To Build Fake Dynamic API"},"content":{"rendered":"\n<p>Sometimes developers face a situation in which they are approaching the deadline of project demo, but the back-end is unlikely to be done before the deadline. It may happens to you that you are working on a front-end project which the back-end API is not ready to serve the request you from front-end. <a href=\"https:\/\/github.com\/birddevelper\/MockiMouse\" data-type=\"URL\" data-id=\"https:\/\/github.com\/birddevelper\/MockiMouse\" target=\"_blank\" rel=\"noreferrer noopener\">MockiMouse <\/a>is an easy to use, and an easy to run mock server that helps you make dynamic fake API to test or demo your front-end project without waiting for back-end team to deliver the real APIs you need. In a few lines of YAML file you can config your fake server to generate fake response data and start serving requests coming from front-end. You can find the project and its binaries on its <a href=\"https:\/\/github.com\/birddevelper\/MockiMouse\" data-type=\"URL\" data-id=\"https:\/\/github.com\/birddevelper\/MockiMouse\" target=\"_blank\" rel=\"noreferrer noopener\">github repository<\/a>.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/birddevelper\/MockiMouse\/releases\/download\/v1.0.0\/mockimouseWin64.zip\" data-type=\"URL\" data-id=\"https:\/\/github.com\/birddevelper\/MockiMouse\/releases\/download\/v1.0.0\/mockimouseWin64.zip\">Download win64 binary of MockiMouse from here<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/birddevelper\/MockiMouse\" data-type=\"URL\" data-id=\"https:\/\/github.com\/birddevelper\/MockiMouse\">Source code on Github<\/a> :<\/p>\n\n\n<div class=\"ebg-br-wrapper ebg-br-wrapper-dark-mode-off\">\n\t<div class=\"ebg-br-background-image\"><\/div>\n\t<div class=\"ebg-br-editmode egb-br-darkmode-status\">\n\t\t<span class=\"egb-br-darkmode-status-img\">Dark Mode<\/span>\n\t<\/div>\n\t<div class=\"ebg-br-avatar\">\n\t\t<img loading=\"lazy\" decoding=\"async\" class=\"ebg-br-header-avatar\" src=\"https:\/\/avatars.githubusercontent.com\/u\/20352967?v=4\" alt=\"\" width=\"150\" height=\"150\" \/>\n\t<\/div>\n\t<div class=\"ebg-br-main\">\n\t\t<p class=\"ebg-br-title\">\n\t\t\t<strong>\n\t\t\t\t<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/birddevelper\/MockiMouse\">\n\t\t\t\t\tMockiMouse\n\t\t\t\t\t<span class=\"screen-reader-text\">(this link opens in a new window)<\/span>\n\t\t\t\t<\/a>\n\t\t\t<\/strong>\n\t\t\t<em>\n\t\t\t\tby<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/birddevelper\">\n\t\t\t\t\tbirddevelper\n\t\t\t\t\t<span class=\"screen-reader-text\">(this link opens in a new window)<\/span>\n\t\t\t\t<\/a>\n\t\t\t<\/em>\n\t\t<\/p>\n\t\t<p class=\"ebg-br-description\">MockiMouse helps you create dynamic fake API (mock server) to test or demo your front-end<\/p>\n\t\t<p class=\"ebg-br-footer\">\n\t\t\t<span class=\"ebg-br-subscribers\">\n\t\t\t\t<span class=\"ebg-br-background-image\"><\/span>\n\t\t\t\t1 Subscriber\t\t\t<\/span>\n\t\t\t<span class=\"ebg-br-watchers\">\n\t\t\t\t<span class=\"ebg-br-background-image\"><\/span>\n\t\t\t\t4 Watchers\t\t\t<\/span>\n\t\t\t<span class=\"ebg-br-forks\">\n\t\t\t\t<span class=\"ebg-br-background-image\"><\/span>\n\t\t\t\t0 Forks\t\t\t<\/span>\n\t\t\t<a target=\"_blank\" rel=\"noopener noreferrer\" class=\"ebg-br-link\" href=\"https:\/\/github.com\/birddevelper\/MockiMouse\">\n\t\t\t\tCheck out this repository on GitHub.com\t\t\t\t<span class=\"screen-reader-text\">(this link opens in a new window)<\/span>\n\t\t\t<\/a>\n\t\t<\/p>\n\t<\/div>\n<\/div>\n\n\n<p>Let&#8217;s go to the point! First, I start from a simplest possible case where we want to mock two simple API that always send same response to client. Open config.yml file and past below configuration in it, then start the server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"yaml\" class=\"language-yaml\">MockServer&nbsp;:\n&nbsp;port&nbsp;:&nbsp;800\n&nbsp;endpoints&nbsp;:\n&nbsp;&nbsp;-&nbsp;name&nbsp;:&nbsp;Hello world endpoint\n&nbsp;&nbsp;&nbsp;&nbsp;path&nbsp;:&nbsp;\/hello\n&nbsp;&nbsp;&nbsp;&nbsp;method&nbsp;:&nbsp;GET\n&nbsp;&nbsp;&nbsp;&nbsp;scenarios&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;description&nbsp;:&nbsp;no&nbsp;condition,&nbsp;always&nbsp;show&nbsp;same&nbsp;message\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response:&nbsp;\n         - Welcome to&nbsp;Hello&nbsp;world \n&nbsp;&nbsp;-&nbsp;name&nbsp;:&nbsp;Goodbye endpoint\n&nbsp;&nbsp;&nbsp;&nbsp;path&nbsp;:&nbsp;\/goodbye\n&nbsp;&nbsp;&nbsp;&nbsp;method&nbsp;:&nbsp;POST\n&nbsp;&nbsp;&nbsp;&nbsp;scenarios&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;description&nbsp;:&nbsp;no&nbsp;condition,&nbsp;always&nbsp;show&nbsp;goodbye\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response:&nbsp;\n         - Goodbye. See you later<\/code><\/pre>\n\n\n\n<p>As you can see The config starts with <strong>MockServer <\/strong>root, then with <strong>port <\/strong>parameter you can choose on which port you want to start the mock server. That&#8217;s not the only parameter you can set for the server, the <strong>contextPath <\/strong>for APIs and <strong>staticFilesPath <\/strong>are to other optional parameters of server :<\/p>\n\n\n\n<ul>\n<li><strong>contextPath <\/strong>: With this parameter you can place a prefix path part for all APIs. For example you can put <strong>\/api<\/strong> in path to all endpoints. Then endpoints would be exposed like <strong>server-address:port<span class=\"has-inline-color has-vivid-red-color\">\/api<\/span>\/yourEndpoint<\/strong><\/li>\n\n\n\n<li><strong>staticFilesPath <\/strong>: Besides the MockiMouse.exe, you can find a folder named <strong>assets<\/strong>. Static files that you put in this folder can be accessed under <strong>server-address:port<span class=\"has-inline-color has-vivid-red-color\">\/<\/span>assets\/ <\/strong>path, e.g <strong>server-address:port<span class=\"has-inline-color has-vivid-red-color\">\/<\/span>assets\/photo.jpg<\/strong>. With <strong>staticFilesPath <\/strong>parameter you can change the path to these files.<\/li>\n<\/ul>\n\n\n\n<p> Then in <strong>endpoints<\/strong> parameter which is an array, you can declare endpoints and their specifications. Every endpoint accepts following paramters :<\/p>\n\n\n\n<ul>\n<li><strong><span class=\"has-inline-color has-vivid-green-cyan-color\">name <\/span><\/strong>:  It&#8217;s an arbitrary title you can choose for your endpoint<\/li>\n\n\n\n<li><strong><span class=\"has-inline-color has-vivid-green-cyan-color\">path <\/span><\/strong>: It&#8217;s the path to call endpoint. You can also define path parameter with colon prefix like<strong> \/person\/:personId<\/strong> or \/<strong>api\/product\/:id\/history<\/strong><\/li>\n\n\n\n<li><strong><span class=\"has-inline-color has-vivid-green-cyan-color\">accepts <\/span><\/strong>: It&#8217;s an optional parameter that you can use to restrict the client to send specific content-type such as <strong>application\/json<\/strong> , <strong>text\/plain<\/strong>, <strong>application\/xml<\/strong>. You can set multiple content-type separated with space. If the parameter be omitted , no restriction will be placed on the requests.<\/li>\n\n\n\n<li><strong><span class=\"has-inline-color has-vivid-green-cyan-color\">method <\/span><\/strong>: As the parameter name is clear, it define the HTTP method of the endpoint, MockiMouse supports <strong>GET<\/strong>, <strong>POST<\/strong>, <strong>PUT<\/strong>, <strong>PATCH <\/strong>and <strong>DELETE <\/strong>methods. This parameter is mandatory.<\/li>\n\n\n\n<li><strong><span class=\"has-inline-color has-vivid-green-cyan-color\">delay <\/span><\/strong>: With delay parameter you make the endpoint to wait N <strong>millisecond <\/strong>before responding to client. It&#8217;s optional and the default value is <strong>0<\/strong>.<\/li>\n\n\n\n<li><strong><span class=\"has-inline-color has-vivid-green-cyan-color\">scenario <\/span><\/strong>: The last and most important parameter of endpoint which I describe it in this article.<\/li>\n<\/ul>\n\n\n\n<p>So, a sample endpoint configuration can be like this :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"yaml\" class=\"language-yaml\">MockServer&nbsp;:\n&nbsp;contextPath&nbsp;:&nbsp;\/api  # a prefix path for all endpoints\n&nbsp;port&nbsp;:&nbsp;800\n&nbsp;endpoints&nbsp;:\n&nbsp;&nbsp;-&nbsp;name&nbsp;:&nbsp;Login&nbsp;endpoint\n&nbsp;&nbsp;&nbsp;&nbsp;path&nbsp;:&nbsp;\/login # the actual address of endpoint is 127.0.0.1:800\/api\/login\n&nbsp;&nbsp;&nbsp;&nbsp;accepts&nbsp;:&nbsp;application\/json text\/plain\n&nbsp;&nbsp;&nbsp;&nbsp;method&nbsp;:&nbsp;POST\n&nbsp;&nbsp;&nbsp;&nbsp;delay&nbsp;:&nbsp;3000\n&nbsp;&nbsp;&nbsp;&nbsp;scenarios&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...\n\n&nbsp;&nbsp;-&nbsp;name&nbsp;:&nbsp;Logout endpoint\n&nbsp;&nbsp;&nbsp;&nbsp;path&nbsp;:&nbsp;\/logout # the actual address of endpoint is 127.0.0.1:800\/api\/logout\n&nbsp;&nbsp;&nbsp;&nbsp;accepts&nbsp;:&nbsp;application\/json \n&nbsp;&nbsp;&nbsp;&nbsp;method&nbsp;:&nbsp;GET\n&nbsp;&nbsp;&nbsp;&nbsp;delay&nbsp;:&nbsp;1000\n&nbsp;&nbsp;&nbsp;&nbsp;scenarios&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Scenario<\/h2>\n\n\n\n<p>Scenario is combination of one or several conditions that result to specific response. For example, in login endpoint we have two scenarios.First scenario is when client send valid username and password to the endpoint, and second scenario is when client send invalid username and password to the endpoint. For each of these two situations, we can send corresponding response. It helps front-end developer to test all possible scenario of it&#8217;s project. Let&#8217;s see what happens in yaml config for described scenarios :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"yaml\" class=\"language-yaml\">MockServer&nbsp;:\n&nbsp;contextPath&nbsp;:&nbsp;\/api\n&nbsp;port&nbsp;:&nbsp;800\n&nbsp;endpoints&nbsp;:\n&nbsp;&nbsp;-&nbsp;name&nbsp;:&nbsp;Login&nbsp;endpoint\n&nbsp;&nbsp;&nbsp;&nbsp;path&nbsp;:&nbsp;\/login\n&nbsp;&nbsp;&nbsp;&nbsp;accepts&nbsp;:&nbsp;application\/json\n&nbsp;&nbsp;&nbsp;&nbsp;method&nbsp;:&nbsp;POST\n&nbsp;&nbsp;&nbsp;&nbsp;delay&nbsp;:&nbsp;3000\n&nbsp;&nbsp;&nbsp;&nbsp;scenarios&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;description&nbsp;:&nbsp;When&nbsp;credential&nbsp;is&nbsp;valid\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;condition&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name&nbsp;:&nbsp;username #paramter name\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type&nbsp;:&nbsp;body\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;operand&nbsp;:&nbsp;equal \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value&nbsp;:&nbsp;admin\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name&nbsp;:&nbsp;password\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type&nbsp;:&nbsp;body\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;operand&nbsp;:&nbsp;equal\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value&nbsp;:&nbsp;1234\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response:&nbsp;\n         - file:\/\/helloWorld.json\n         - url:\/\/some-addresss\/path\/to\/hi.json\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;description&nbsp;:&nbsp;When&nbsp;credential&nbsp;is&nbsp;invalid\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;condition&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name&nbsp;:&nbsp;username\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type&nbsp;:&nbsp;body\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;operand&nbsp;:&nbsp;equal\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value&nbsp;:&nbsp;admin\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name&nbsp;:&nbsp;password\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type&nbsp;:&nbsp;body\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;operand&nbsp;:&nbsp;notEqual\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value&nbsp;:&nbsp;1234\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response&nbsp;:&nbsp;\n         - file:\/\/invalidCredintial.json\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;status&nbsp;:&nbsp;200<\/code><\/pre>\n\n\n\n<p>Here the art of MockiMouse starts. Except the scenario part, we are familiar with above configuration. The scenario consist of a condition that a request should meet to trigger that scenario. The condition may involve one or several parameters. <strong>For example, in the above configuration, for valid scenario, we need the client to send &#8220;admin&#8221; as username and &#8220;1234&#8221; as password.<\/strong> So, I declared two parameter and their expected value in condition part of scenario.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"yaml\" class=\"language-yaml\">       ...\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;condition&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;param&nbsp;:\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name&nbsp;:&nbsp;username\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type&nbsp;:&nbsp;body # it means the username is a post body json parameter\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;operand&nbsp;:&nbsp;equal # it means we need the username be equal to following value\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value&nbsp;:&nbsp;admin\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&nbsp;name&nbsp;:&nbsp;password\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type&nbsp;:&nbsp;body\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;operand&nbsp;:&nbsp;equal\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value&nbsp;:&nbsp;1234\n\n       ...<\/code><\/pre>\n\n\n\n<p>So each param takes following paramters :<\/p>\n\n\n\n<ul>\n<li><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">name <\/span><\/strong>: The name of parameter. For JSON parameters it can be a path like order.id or student.birthplace.city<\/li>\n\n\n\n<li><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">type <\/span><\/strong>:  MockiMouse gives access of all kind of parameters to let the fake API behave exactly like it&#8217;s real one. You can retrieve parameters from <strong>header, form, query, body and path<\/strong>. I think they don&#8217;t need further explanation. Just set the type of param to one of these keyword to get the value of parameter in the by its name.<\/li>\n\n\n\n<li><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">operand <\/span><\/strong>: It&#8217;s not like that in every condition we only want the parameter to be equal to a value. We also need <strong>notEqual, greaterThan, lessThan, greaterEqual, lessEqual, contain.<\/strong> <\/li>\n\n\n\n<li><strong><span class=\"has-inline-color has-vivid-cyan-blue-color\">value <\/span><\/strong>: It&#8217;s the value that we want to compare the parameter with it.<\/li>\n<\/ul>\n\n\n\n<p>After specifying the condition in the scenario with its parameters, we can say which response and what kind of response to send as response. We do it by <strong>response, status <\/strong>and <strong>contentType<\/strong> parameters. <\/p>\n\n\n\n<ul>\n<li><strong><span class=\"has-inline-color has-vivid-red-color\">response <\/span><\/strong>: It accepts list of response. Each of response in the list can be <strong>text, file or url<\/strong>. To read the response from the file, just add <strong>file:\/\/<\/strong> prefix to the response value like :<strong> file:\/\/jsonProducts.js<\/strong>, or <strong>http:\/\/anyserver.com\/resp.xml<\/strong> to read from a remote url. It should be notice that if you want to read from the file, you should place the file in the <strong>responses folder<\/strong> of MockiMouse beside the server executable file. If your response list contains more than one response, each time the scenario matches, it will choose a response from the list randomly.<\/li>\n\n\n\n<li><strong><span class=\"has-inline-color has-vivid-red-color\">status <\/span><\/strong>: The <strong>status<\/strong> parameter accept all status code, and its default is 200. <\/li>\n\n\n\n<li> <strong><span class=\"has-inline-color has-vivid-red-color\">contentType <\/span><\/strong>: accept all possible content type such as text\/html, application\/json, application\/xml and etc.<\/li>\n<\/ul>\n\n\n\n<p> Finally, to run the project, just run the executable mockimouse.exe, if you have done the configuration well you should see the below message :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/m-shaeri.ir\/blog\/wp-content\/uploads\/2023\/01\/mockimouse_mock_server_fake_api.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"914\" height=\"294\" src=\"https:\/\/m-shaeri.ir\/blog\/wp-content\/uploads\/2023\/01\/mockimouse_mock_server_fake_api.jpg\" alt=\"mockimouse_mock_server_fake_api\" class=\"wp-image-1258\" srcset=\"https:\/\/mshaeri.com\/blog\/wp-content\/uploads\/2023\/01\/mockimouse_mock_server_fake_api.jpg 914w, https:\/\/mshaeri.com\/blog\/wp-content\/uploads\/2023\/01\/mockimouse_mock_server_fake_api-300x96.jpg 300w, https:\/\/mshaeri.com\/blog\/wp-content\/uploads\/2023\/01\/mockimouse_mock_server_fake_api-768x247.jpg 768w\" sizes=\"(max-width: 914px) 100vw, 914px\" \/><\/a><figcaption class=\"wp-element-caption\">mockimouse mock server to create fake api<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Dockerizing The Mock Server<\/h2>\n\n\n\n<p>You can build source code of MockiMouse and make a docker image serving as a mock server using docker file :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"docker\" class=\"language-docker\">FROM&nbsp;golang:1.19\n\n#&nbsp;The&nbsp;exposed&nbsp;port&nbsp;should&nbsp;be&nbsp;changed&nbsp;to&nbsp;port&nbsp;number&nbsp;you&nbsp;specified&nbsp;in&nbsp;MockiMouse&nbsp;config.yml\nEXPOSE&nbsp;800\nWORKDIR&nbsp;\/MockiMouse\n\n#&nbsp;Copy&nbsp;source&nbsp;code&nbsp;to&nbsp;working&nbsp;directory\nCOPY&nbsp;.&nbsp;.\n\n#&nbsp;Build&nbsp;source&nbsp;code&nbsp;to&nbsp;mockimouse&nbsp;binary\nRUN&nbsp;go&nbsp;build&nbsp;.\n\n#&nbsp;Start&nbsp;MockiMouse&nbsp;server\nCMD&nbsp;.\/mockimouse<\/code><\/pre>\n\n\n\n<p>You can deploy it beside your frontend container with docker compose, or even deploy it on a cloud base infrastructure to serve your frontend demo project.<\/p>\n\n\n\n<p>Hope you find this mock server useful. If you liked it please don&#8217;t forget to <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/birddevelper\/MockiMouse\" data-type=\"URL\" data-id=\"https:\/\/github.com\/birddevelper\/MockiMouse\" target=\"_blank\">give it a star on github<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes developers face a situation in which they are approaching the deadline of project demo, but the back-end is unlikely to be done before the &hellip; <\/p>\n","protected":false},"author":1,"featured_media":1266,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,195,139,142,74,94,193,35,194],"tags":[189,192,186,188,67,185,191,84,187,190],"_links":{"self":[{"href":"https:\/\/mshaeri.com\/blog\/wp-json\/wp\/v2\/posts\/1259"}],"collection":[{"href":"https:\/\/mshaeri.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mshaeri.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mshaeri.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mshaeri.com\/blog\/wp-json\/wp\/v2\/comments?post=1259"}],"version-history":[{"count":1,"href":"https:\/\/mshaeri.com\/blog\/wp-json\/wp\/v2\/posts\/1259\/revisions"}],"predecessor-version":[{"id":1881,"href":"https:\/\/mshaeri.com\/blog\/wp-json\/wp\/v2\/posts\/1259\/revisions\/1881"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mshaeri.com\/blog\/wp-json\/wp\/v2\/media\/1266"}],"wp:attachment":[{"href":"https:\/\/mshaeri.com\/blog\/wp-json\/wp\/v2\/media?parent=1259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mshaeri.com\/blog\/wp-json\/wp\/v2\/categories?post=1259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mshaeri.com\/blog\/wp-json\/wp\/v2\/tags?post=1259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}