boyney123 / mockit Goto Github PK
View Code? Open in Web Editor NEWA tool to quickly mock out end points, setup delays and more...
Home Page: https://mockit.netlify.com/
License: MIT License
A tool to quickly mock out end points, setup delays and more...
Home Page: https://mockit.netlify.com/
License: MIT License
first of all, mockit is great work.
it can be very good if you there is a feature that I can easily export and import my routes. for backing up stuff or sending to another one.
imagine that, I'm backend guy. and my front end guys wants to integrate with API. but API is under development, so I can mock my API and export my setting and routes and send it to my front developer. and then front developer than simply import my exported data, and use API and integrate with that.
I'm interested in to bring this feature.
Followed the docs.
Well, both versions of the docs, since the site and the readme have different 'Getting started' steps.
sh: build-and-start.sh: No such file or directory
Step 5/9 : COPY package-lock.json . ERROR: Service 'mockit-server' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder079289765/package-lock.json: no such file or directory
I would love to give this a chance, but am unable.
Not sure if this is me missing an 'obvious' but undocumented step, or if it's something that's missing in the repo.
Because I originally connected Snyk to my GitHub fork of the mockit repository I am now getting automatic fix PRs from Snyk to resolve security issues - while it's nice, it serves little purpose on my own fork :)
Security vulnerabilities affecting mockit need to be addressed.
See the PR here: lirantal#1
Perhaps connect to Snyk with your GitHub account and this monitor this repository so it is able to automatically open fix PRs to mitigate security issues.
See example PR in my fork:
I want to standardify code style in project. What you say, @boyney123 ?
mockit-docs.netlify.com
Not Found
What you did:
See of opeanpi/swagger specs were supported.
What happened:
OpenAPI v2 (Swagger) and OpenAPI v3 are not supported.
Problem description:
Suggested solution:
Add support for serving openapi v2 (swagger) and openapi v3 specifications. A lot of people already use openapi v2/3 to document and provide examples for their apis. There is a lack of good mocking tools around openapi, it'd be great if mockit supported serving an openapi specification. Supporting both versions of the OpenAPI format (v2/v3) would be ideal as a large amount of tooling and specs already exist around v2 (formerly swagger).
Hi there @boyney123
First of all, thanks for your brilliant work!
cd mockit-routes
npm install
npm run start
Then visit http://localhost:3000/random
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
the headers
in routes.json should be an array of {header, value}
objects as it is in root's routes.json
Update mockit-routes/configuration/routes.json
...
"headers": [{
"header": "x-testing",
"value": "tester"
}, {
"header": "x-testing2",
"value": "tester2"
}, {
"header": "x-testing3",
"value": "tester3"
}],
...
Successfully built f693cc17ca19
Creating network "mockit_default" with the default driver
Pulling mockit-client (mockit-client:latest)...
ERROR: repository mockit-client not found: does not exist or no pull access
bogon:mockit xxxx$
docker image (mockit-client) not exist
Add the ability to specify key => value response headers per endpoint.
At the moment MockIt supports
export const StatusCodes = {
OK: "200",
CREATED: "201",
NO_CONTENT: "204",
BAD_REQUEST: "400",
FORBIDDEN: "401",
INTERNAL_SERVER_ERROR: "500"
};
Might be worth adding some more? https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
If anybody is up for the challenge :)?
Hi, i am hosting this on a CentOS server, this allows me and a friend to use it. I can access it but i am unable to save any changes on the console.
When i try to save the changes to the path, i see it tries to save too localhost.
-> PUT http://localhost:4000/route where it should be saving to our server which in this case is something else.
I can access it, but looks like configurations are pointing to local host instead of the host where it is deployed on.
Could you please commit an update that has a fix for this ? thanks so much!
In order to support building the compose images within a corporate network, a set of .nmprc files must be added to the client / server / mockit-routes with "strict-ssl=false". Then the .npmrc file must be mounted prior to execute the stage npm ci.
in your install script, you used npm install. so there is a little difference between npm install and npm ci. https://stackoverflow.com/questions/52499617/what-is-the-difference-between-npm-install-and-npm-ci, according to this, it's better to use npm ci when we have package-lock.json for better performances and preventing re-generate package-lock.json in another systems.
if you agree with me, I would like to send you a PR for that.
From what I can tell the client tests are not running, due to some changes in create-react-app
3.0, and the path they use under the hood for the jest tests.
What you did:
Installed it and have started playing around with it... this is awesome, thank you so much for developing it and putting it out there!
Problem description:
There are times when I want the same route to respond with a different payload. For example, suppose testing how a collection/list of objects displays with attributes set differently / no objects / one / many, etc. It would be neat to have this be supported really well.
Suggested solution:
Add a 'Duplicate' button in line with 'Edit' and 'Delete' on the index page - this will make it easier to add the same route information over again.
Have the 'Disable Route' checkbox available on the front page.
With these two additions to the UI the process of having responses on the same endpoint would be quicker. A step further would be perhaps grouping together entries that target the same path in the listing.
I literally have an item on my whiteboard 'Quick API for testing' that this just solved, thank you so much. Found it via the HN post =)
It would be great if we can provide JSON schema and API generates data for us.
I tried to create/modify a route
It neither creates a new route not generates an error message. I have tried with the latest version.
Create a route:
/orders/*
then set the delay to 2000ms.
route not delayed when hit with another param beside *
/orders/1
not delayed
/orders/900
not delayed
/orders/*
delayed
Need to handle delay feature for wildcard path.
don't have a suggestion. but please fix it. ๐ฅ
Hello, we would like to feature your project to the Docusaurus users page.
Would that be ok? Also can you provide your logo?
More info about this here
Stop wasting time mocking APIs. MockIt gives you an interface to configure and create REAL mocked end points for your applications
This is sadly untrue, as mockit only supports JSON APIs. Not every service gives us JSON APIs, despite it being 2019...
There is a funny bug in your frontend btw. If you copy-paste html tags with style into the "response" field, your app will try to render it. :)
<!-- try it yourself -->
<div style='width: 500px; background-color: red;'>Hey you!</div>
It would be great if one could configure endpoints to send cookies in the response.
What you did:
What happened:
Problem description:
hitByMonkey
util method is defined as a commonjs export but imported as an ES6 import in mockit-routes/src/middlewares/chaos-monkey/index.js
Suggested solution:
const { hitByMonkey } = require("./util");
to const hitByMonkey = require("./util");
Created a POST route
{ "id": "8e54c04a-21fd-4cb3-b8de-1aa5a9ef988e", "route": "/events", "httpMethod": "POST", "statusCode": "204", "delay": "0", "payload": { "success": true }, "headers": [ { "id": "6ffb195d-c434-46da-a08c-52090415c949", "header": "Retry-After", "value": "60" } ], "disabled": false }
that responds with a HTTP 204 with a simple body of { success: true }
and posted:
curl --request POST '169.254.241.176:3000/events' --header 'Content-Type: application/json' --data-raw '[{"eventId":"fbf1de19-8629-45d3-ad0f-34b8e17d594f","sessionId":"07726e3d-68ed-49a2-bb37-d1372e941191","dateTime":"2020-08-14T01:45:44.975Z","eventType":"App Launched","category":"engagement","latitude":40.4543,"longitude":41.4563},{"eventId":"37314774-d52b-4219-b5c4-e3b2c14aeda0","sessionId":"48830e55-33b2-4a8e-b5c7-710b85b44bf5","dateTime":"2020-08-14T01:56:53.220Z","eventType":"view cart","category":"engagement","latitude":40.4543,"longitude":41.4563,"sku":"abc123","price":10.95},{"eventId":"6c8a2370-0fb0-4c47-8914-11a8e2ffe47f","sessionId":"48830e55-33b2-4a8e-b5c7-710b85b44bf5","dateTime":"2020-08-14T01:57:23.341Z","eventType":"App Launched","category","engagement","latitude":40.4543,"longitude":41.4563}]'
The body isn't delivered for ~90 seconds -- my connection timeout on the client is set to 30 seconds.
Because it should immediately respond and close the connection?
Changing nothing other than the response code back to HTTP 200 fixes the problem (the route responds instantaneously), but I would like to emulate several of the available responses, and I specifically need the 204 response for this POST :)
in mockit/client, I tried to run npm start
after installing dependencies.
npm install failed.
I've installed node-sass through npm, and problems goes away. I'm not sure about it, but maybe it cause because you missed node-sass in dependencies.
Hi Boyney,
I really liked the idea of this tool , but very same thing can be achieved using json-server npm but its not with UI.
One things mockit tool lacks is the ability to Add POST request which accept request body and then post it..
Mockit only and only support FETCHING of data not POSTING of data.
Please make a support for POSTING of data as well
I try to install the module in mockit-routes
and see 62 low severity vulnerabilities.
I think we should up to date them to avoid error unworthily
Copy-pasta from https://mockit.netlify.com/docs/getting-started/installation
git clone [email protected]:boyney123/mockit.git
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
I obviously do not have SSH access to your repo
Change documentation example to git clone https://github.com/boyney123/mockit.git
I have dived into Mockit's code. Overall the idea seems awesome. But I have a few discrepancies to list regarding the project and it's execution:
yarn start
or the likes.What I propose is, for the project to be meaningful and to be integrated into a proper development workflow, we should do the following:
Additionally, we should create an org on GitHub, under which everything will reside. We could follow a mono-repo structure sans Docker, and use Lerna instead. I believe that will solve a lot of the problems, and help give out more meaningful messages in the console to the contributor during development.
Do let me know what you think!
Hi,
I'm wondering if it's somehow possible to see the requests that came into the Mockit instance. This is one of the features that similar services have and it's something that I need in order to see what data are clients sending to the API. I know this is not possible via GUI at the moment, but are there maybe some log files where request data is getting logged?
BR,
Denis
It gives developers another option to run mockit rather than building it locally
I don't sure that I can't know your code style.
(Maybe you use 4 space and 2 space in this project)
So can you use linter for this project(example: eslint
)?
Add this HTML snippet inside the response field. And you will see it render...
<div style='width: 500px; background-color: red;'>Hey you!</div>
It rendered the HTML
I think at the moment mockit will only return JSON responses. It would be nice that HTML does not get rendered as HTML, but also maybe give the user an error if HTML was added?
Option 2: We can try and support HTML as responses but not sure what would be involved.
Really nice work on this project David! Congrats ๐
Great stuff here: Dockerfile uses alpine โ Server-side code doesn't use any packages with known vulnerabilities โ
However I found several vulnerabilities on the frontend related code:
When cloning the project for personal use, Snyk alerts me of security vulnerabilities.
Some of the security vulnerabilities reported on dependent packages can be resolved by using newer versions of them (so an update to the lockfile is needed).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.