Node.js API - Autonomi Paste Application

I’m creating a pastebin style application for autonomi via nextjs.

But I want to use an node/typescript/js API for my application.

Just wondering is this planned and potential timeline.

I think having this API would bring a flood of applications to the network as most developers in the world are in that ecosystem. I’ve more ideas I want to deploy after this one.

9 Likes

With Tauri you can reduce the Rust part to very simple invocations of Autonomi API. Tauri has very good JS APIs to control every aspect of the app.


Check out the Dev Forum

2 Likes

I’m trying to keep this project browser-based node.js, with no rust or tauri.

Most devs are used to that ecosystem.

Plus I’ve enough rust/tauri with building that other application :wink:

1 Like

Hahaha somehow I didn’t notice it’s you @safemedia !

I’m working on a FFI binding generator for Red. But it’s generic enough, so it could generate code also for other languages. If someone could figure out how to interface NodeJS with Rust on just one function [1] [2] like init(), the rest could be automatically generated.

[1] sn_ffi/sn-ffi.red at master · loziniak/sn_ffi · GitHub
[2] sn_ffi/sn_ffi/src/lib.rs at master · loziniak/sn_ffi · GitHub

3 Likes

Currently there are no Node.js bindings, though this is definitely something we want in the near future.

However, this would be a Node.js module which would not run in the browser. We experimented with a browser compatible library a while ago that used websockets, but this turned out to be quite inefficient and a horrible experience.

If I understand your use-case correctly, a perfectly reasonable approach would be to use a Rust back-end. When you’re looking to build a traditional website, you can use something like Actix for an HTTP back-end API. In that case you can use any front-end framework you like, like Svelte.

3 Likes

I’d prefer to keep the code client-side without relying on a backend on a server. (assuming this is what is meant regarding the browser not being performant enough)

Perhaps it might make sense to build some browser extension that can interface with a locally running node on the client computer. So that all browser only dapps could send API requests to the local node?

Just to be clear. Browser based XX (js/wasm etc.) cannot see networks like UDP/TCP/QUIC etc. or filesystems. You can get some web socket or webrtc stuff, but our nodes don’t speak that protocol.

So a browser based thing cannot see databases and filesystems outside the browser without a backend, i.e. rust/python/nodejs module etc. That means you are limited to what’s in the browser as opposed to what’s on the network or on disk. We pushed WASM as much as possible to get down that road, but we had to give up. You need WASI and that is still developing.

So like @bzee said, you need more to get to the network / disk and that will mean a backend of some sort, unfortunately

3 Likes

This is also a possibility. And it’s similar to what was done many years ago with the Safe browser. I think an extension was also considered, but it didn’t allow apps to be sandboxed to safenet only (e.g. it could still communicate with ‘clearnet’) so it was decided to build a sandboxed browser that had an extra client API to communicate with the network.

An extension is an interesting approach. It doesn’t need a node by the way, it can just use the native Autonomi client API to fetch and store data (as long as there is a topped up wallet attached).

2 Likes

I’ll try and build a proof of concept soon :+1:

2 Likes

Fwiw, this is one of the use cases AntTP was for.

Instead of a custom browser, you just use a regular browser with a (local) proxy to AntTP.

That said, AntTP doesnt quite have POST support to upload files/archives yet. It’s in progress though.

Edit: To add, I am freestyling the interface at the moment. AntTP will approximate a HTTP wrapper around the Autonomi API, to expose API features. The team may want to give input if folks start depending on it for app dev though.

3 Likes

I remember IPFS has an extension as well, it was a big thing, but I am not sure how well it went. I have not heard much since, but as we also use libp2p there may be something?

I have this MVP 90% complete, if you DM me I can invite you to the three repos. (web application, extension and local application that acts as a wrapper for the autonomi API.

General idea: web application sends requests via the web extension which routes it to the local application.

Just running the web application locally for testing, but will also work deployed.

Extension:

The local API wrapper is a tauri client

6 Likes