Avatar

patrick_kw_chiu

Joined August 19, 2023
Likes
2
std avatar
turso
@std
Script
Deprecated in favor of std/sqlite (also powered by Turso) std/turso was the initial version of our integration with Turso. It was so popular, we rebuilt it to be faster and easier to use: std/sqlite . Turso is a serverless SQLite platform designed for the edge. It runs libSQL , their open contribution fork of SQLite. Every Val Town user automatically gets their own Turso SQLite database! It's great for >100kb data (ie bigger than a val) or when you need SQL: relations, ACID transactions, etc. Storage used in Turso will count against your Val Town total storage (10mb for free users; 1gb for Pro users). Contact us if you'd need more – it should be no problem! Getting started This val uses our public key auth scheme . Generate your keypair On your publicKey click the lock icon🔒 to change the permissions to Unlisted . Fork this helper function replacing stevekrouse with your own username Try out some queries! Usage This val returns a Turso SDK's Client , which supports execute , batch , and transaction . await @me.turso().execute(`create table blobs( key text unique, value text )`) More example usage Architecture This @std.turso function is the client or SDK to @std.tursoAPI, which acts as a "proxy" to Turso. It handles authentication, creates databases, and forwards on your SQL queries. You can get lower latency (~200ms vs ~800ms), more storage, databases, CLI & API access by having your own Turso account.
stevekrouse avatar
r2
@stevekrouse
Script
r2 wrapper Save blobs without leaving Val Town! Only for Val Town Pro users to limit abuse. We get 10gb free, so as long as nobody abuses this, I won't put any strict limits on it. If you want to use more than 10gb, let me know, and we can bill you for it. All data in this bucket is public if you know it's name! This val, @stevekrouse.r2, is the "SDK" for @stevekrouse.r2Proxy . Setup This val requires you to setup public key auth, which is really just three clicks here: https://blog.val.town/public-key-auth-val-town-users-can-be-your-users [Optional] You can setup a helper function so you don't have to pass your keys every time: let blob = (key, value) => @stevekrouse.r2(key, value, @me.exportedKeys) Warning: Do not make your blob function public or unlisted. That would allow anyone to use it. Usage await @me.blob("demo", { hello: "world" }); return @me.blob("demo"); // {hello: "world"} Example usage: https://www.val.town/v/stevekrouse.r2Demo
Next