HTTP Requests with Space Lua

I’m really interested in using Space Lua, as my Javascript skills are stuck in the ES5 era and I would love to just add some code to implement nifty things.

One thing I would like to implement, is a small script that fetches some issues from a GitLab instance, using an API token. It’s a simple API call, with which I hope to show the tickets I have to work on, on my Silverbullet dashboard.

Is there a way to do that yet? Or is this a planned feature?

I guess there are some security implications, but at the same time this would be a real powerful feature, both on the client and on the server side.

Anyway, cheers for Silverbullet. I really enjoy using it!

I do not use it (yet), but there is a PLUG for such things:

Not LUA based, but as far as I understand, it might server your purpose.

EDIT:
Sorry misread your post. You want GITLAB, not GITHUB :wink:

There is no API to make HTTP calls from Lua yet, but it’s on my list :+1: I’ll move it up my list a bir since there is demand. Should be easy to add.

Nice, thank you!

To clarify: Even if there was a Plug that handles GitLab, I can still think of a number of things that I could do with an HTTP client in space-lua. To me, it’ll further enable me to customize my instance to my exact needs.

Having a low-barrier for that is really exciting to me, because there are going to be tools for which there is no plugin, and there are going to be situations where I just want something quick and dirty to work.

But I guess I’m preaching to the choir :slight_smile:

Yes you are :nerd_face: I completely see how making HTTP requests unlocks tons of things.

Ok, just added something (on Edge). Try it: API/http

Note that this proxies HTTP requests through the server, otherwise you’d run into all types of CORS issues. Let me know how it works for you.

2 Likes

So fast :sweat_smile:

I pulled the edge container, verified that it has the latest sha sha256:9c855fd68badcfa439d907e6c54106f74de4c3fb727653760305f1cb45fa7c5b, but I’m afraid I may not be holding it right:

The part beneath the error is just ${xkcd()}. Here’s the script if you want to copy it:

function xkcd()
  return http.request("https://xkcd.com/info.0.json")
end

Let me know if I missed something in the docs on how to run this. I made sure to reload the system (I even restarted the container for good measure).

Try reloading your client 3x and see if that helps. Caching.

Ah that did it, thank you! I’ll have to dive into this more over the coming days, but a simple test worked :slight_smile:

2 Likes

Would it be possible to add a verify parameter? I have some URLs that use an internal CA that is not available inside the container.

I can add it to the container, but that may not be feasible in all cases.

1 Like

I did some searching and it seems Deno has a --unsafely-ignore-certificate-errors flag you can use when running. This would disable these checks globally. If you run SilverBullet with deno directly you can try adding that flag, for the Docker version I’d have to expose this somehow using an environment variable.

Thanks for the hint. I’ve switched to using deno directly for the time being, and now my requests go through :slight_smile:

1 Like