squint 2024-11-19

got http server working that talks to pg https://github.com/yogthos/squint-http-server

🎉 2

@borkdude let me know if you think anything can be improved there, and I can make a pr for examples

the whole async thing in js kills me inside 😅

What are the current limitations of protocols in squint? I started adapting a library to work with squint, but I've run into a few issues. Most were relatively minor -- for example, :extend-with-metadata isn't supported, and docstrings can't be included in the protocol's methods. However, it also looks like extend-protocol isn't supported.

@tmcothran feel free to post issues about those with repros, then I'll have a look at each one of them

I posted the docstring one to github. I think extend-protocol was the result of trying to extend a type that exists in CLJS but not squint. Testing that theory now

@tmcothran extend-protocol to nil is also fixed

i like it on the first skim. The fact you are using the basic http server is awesome 😄. I would have thought that you would use something like express or better hapi

maybe i'll check hapi how it works in squint cause it looks like a good fit. Its data first

@ales.najmann also posted a hono example recently in this channel

(not familiar with it, so I can't say I endorse it or not)

@mathaeus.peter.sander oh yeah for anything more serious using something like express would probably make sense, in my case I just have a minimal lambda API I'm using this for, so went with the most basic thing available 🙂

👍 1
💯 1

I would have done the same

😀 1

Makes sense. I'd still use Hono even for that since it has uniform APIs for such things (cloudflare workers, cloud functions etc).

oh yeah that could be handy

my familiarity with the js ecosystem is very minimal

don't worry, I also do this "only on fridays" kinda 😞

I find the async part trips me up the most with js, I'm just not used to thinking in this way and even with using stuff like await I still find there are things that trip you up

for example (.-rows (js-await (.query pool query params))) having to do js-await before you can grab rows is easy to miss, and then the errors you get aren't terribly helpful

and once you have an async function happening then everything that calls it has to deal with promises, and it's the whole callback hell business 🙂

it's not too bad if you can keep this at the edges though

@yogthos About the PR, maybe we can just make a link to your repo. All these involved examples increase the maintenance burden for me when something is out of date and I don't like to have to run databases etc just for an example :)

oh sure yeah

makes sense, testing does get gnarlier this way

Basic version of https://squint-cljs.github.io/squint/?src=KHJlcXVpcmUgJ1tjbG9qdXJlLnN0cmluZyA6YXMgc3RyXSkKCihkZWZjbGFzcyBSYXdTdHJpbmcKICAoZmllbGQgLXMpCiAgKGNvbnN0cnVjdG9yIFtfIHNdCiAgICAoc2V0ISAtcyAoc3RyIHMpKSkKICBPYmplY3QKICAodG9TdHJpbmcgW19dCiAgICAtcykpCgooZGVmbiAtPmF0dHJzIFttXQogIChpZiAobWFwPyBtKQogICAgKHN0ci9qb2luICIgIgogICAgICAoZm9yIFtbayB2XSBtXQogICAgICAgIChzdHIgKHN0ciBrKSAiPVwiIiAoc3RyIHYpICJcIiIpKSkKICAgIChodG1sIG0pKSkKCihkZWZuIGh0bWwgW3hdCiAgKGlmIChpbnN0YW5jZT8gUmF3U3RyaW5nIHgpIHgKICAgIChsZXQgW3JlcyAoY29uZAogICAgICAgICAgICAgICAgKHZlY3Rvcj8geCkKICAgICAgICAgICAgICAgIChsZXQgW1thdHRycyBjaGlsZHJlbl0gKHJlc3QgeCkKICAgICAgICAgICAgICAgICAgICAgIFthdHRycyBjaGlsZHJlbl0gKGlmIChtYXA%2FIGF0dHJzKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFthdHRycyBjaGlsZHJlbl0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBbbmlsIChjb25zIGF0dHJzIGNoaWxkcmVuKV0pXQogICAgICAgICAgICAgICAgICAoc3RyCiAgICAgICAgICAgICAgICAgICAgIjwiIChmaXJzdCB4KSAod2hlbiBhdHRycwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoc3RyICIgIgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgtPmF0dHJzIGF0dHJzKSkpICI%2BIgogICAgICAgICAgICAgICAgICAgIChodG1sIGNoaWxkcmVuKQogICAgICAgICAgICAgICAgICAgICI8LyIgKGZpcnN0IHgpICI%2BIikpCiAgICAgICAgICAgICAgICAoc2VxPyB4KQogICAgICAgICAgICAgICAgKHN0ci9qb2luICIgIiAobWFwIGh0bWwgeCkpCiAgICAgICAgICAgICAgICAobmlsPyB4KSAiIgogICAgICAgICAgICAgICAgOmVsc2UgKHN0ciB4KSldCiAgICAgIChuZXcgUmF3U3RyaW5nIHJlcykpKSkKCihzdHIgKGh0bWwgWzpkaXYgWzphIHs6Y2xhc3MgImR1ZGUifSAxXV0pKQ%3D%3D in squint