HackerTrans
TopNewTrendsCommentsPastAskShowJobs

dhuan_

no profile record

Submissions

Show HN: Dop, Awk-like processing for JSON/YAML/TOML with Lua

github.com
2 points·by dhuan_·4 ay önce·1 comments

Mock – An API creation and testing utility: Examples

dhuan.github.io
137 points·by dhuan_·8 ay önce·19 comments

comments

dhuan_
·2 ay önce·discuss
I have been working on two opensource tools:

https://dhuan.github.io/mock/latest/examples.html Command line utility that lets you build APIs with just one command.

https://github.com/dhuan/dop JSON/YAML manipulation with AWK style approach.
dhuan_
·3 ay önce·discuss
well done! wouldn't it nice if something like this existed in Lua as well (or maybe it does and I haven't seen it yet)?

I've built a data transforming tool powered by Lua[1] and would definitely like to benefit from an general purpose api/library like Lute.

1: https://github.com/dhuan/dop
dhuan_
·3 ay önce·discuss
I have been working on two opensource tools:

https://dhuan.github.io/mock/latest/examples.html

^Command line utility that lets you build APIs with just one command.

https://github.com/dhuan/dop

^JSON/YAML manipulation with AWK style approach.
dhuan_
·3 ay önce·discuss
I have been working on two opensource tools:

https://dhuan.github.io/mock/latest/examples.html

^Command line utility that lets you build APIs with just one command.

https://github.com/dhuan/dop

^JSON/YAML manipulation with AWK style approach.
dhuan_
·3 ay önce·discuss
For me it has to be mock. With it I can create and automate APIs easily.

https://dhuan.github.io/mock/latest/examples.html
dhuan_
·4 ay önce·discuss
I agree, even trivial tasks require us to go back to jq's manual to learn how to write their language.

this and other reasons is why I built: https://github.com/dhuan/dop
dhuan_
·4 ay önce·discuss
mock, an API creation and testing utility. Any feedback is welcome.

https://dhuan.github.io/mock/latest/examples.html
dhuan_
·6 ay önce·discuss
mock, an API creation and testing utility. Any feedback is welcome!

https://dhuan.github.io/mock/latest/examples.html
dhuan_
·7 ay önce·discuss
I’ve found tools like Charles really useful for understanding what’s happening on the wire. When I need something more repeatable (tests, offline work), I usually reach for a mock server instead. I ended up building a small one for my own use and later open-sourced it:

https://dhuan.github.io/mock/latest/examples.html
dhuan_
·7 ay önce·discuss
mock, an API creation and testing utility. Any feedback is welcome!

https://dhuan.github.io/mock/latest/examples.html
dhuan_
·8 ay önce·discuss
Great article. In addition, updating your mocking code can often be time-consuming. To try to make this easier, I built mock[1], which streamlines the process of setting up mock services for testing.

https://dhuan.github.io/mock/latest/examples.html
dhuan_
·8 ay önce·discuss
mock, an API creation and testing utility. Any feedback is welcome!

https://dhuan.github.io/mock/latest/examples.html
dhuan_
·8 ay önce·discuss
It's also possible create an HTTP service that acts as a wrapper to yt-dlp with just a few lines of shell, I created this example in the following link:

https://dhuan.github.io/mock/latest/examples.html#youtube-do...
dhuan_
·8 ay önce·discuss
Swagger is a tool for API design and documentation.

Mock on the other hand is an actual API creation utility with which you can define endpoints, execute some logic for each endpoint and then return some data to the client. There are other similar features which are covered in the user guide.

Mock is not: - A tool for API Specs or documentation - A GUI tool.

I admit explaining the usefulness of this tool is not the easiest thing.

Any feedback is welcome!
dhuan_
·8 ay önce·discuss
I think you intended to post here: https://news.ycombinator.com/item?id=45789474
dhuan_
·8 ay önce·discuss
Hi! Not yet, unless you use it with containers.
dhuan_
·8 ay önce·discuss
Hi, thanks for the feedback! I hope it's useful to you.
dhuan_
·8 ay önce·discuss
Hi, thanks for the feedback!

That's true, it's not a very unique name. I started building it, but only months later I thought of making it public. And then never thought of renaming it.
dhuan_
·8 ay önce·discuss
Hi thanks for the feedback checking out the project.

> What's the main motivation for creating this tool?

Similar tools exist out there for sure, but they are either complex (more than I wish they'd be) or somehow require you to use a specific programming languages. Mock lets you accomplish this without telling you which language you should use.

Also if you're using mock inside CI pipelines, it also helps the fact that you can just download a executable tool that does not require you the java platform or any other dependency.

> How hard/easy is it to make responses dynamic, i.e. to use something from the request data like query/path param or a body to execute function instead of hardcoding the response

With mock you can use shell scripts as "request handlers". With that said, capturing a query param or a JSON field from the request body is as simple as:

> $ USER_NAME=$(mock get-payload user.name)

> $ SOME_QUERY_STRING_PARAM=$(mock get-query foo)

You can see more of this topic here: https://dhuan.github.io/mock/shell_scripts.html

> I feel like every programming language have similar tool already - WireMock for Java etc. Why should people switch?

True. If people are happy with these tools and needing to use java (or any other lang the tool pulls you into), then there's not much reason to switch.
dhuan_
·3 yıl önce·discuss
mock - language agnostic API mocking and testing utility https://github.com/dhuan/mock

I built it because I needed an easy way to set-up API endpoints that weren't implemented yet by some other team. After a while I open-sourced it.

wikicmd https://github.com/dhuan/wikicmd

Navigating through mediawiki to get pages edited all time requires a bunch of clicks. I wanted to be able to quickly edit wiki pages using any editor program instead of the browser.