std avatar
std
email
Script
Email - Docs β†— Send emails with std/email . You can only send emails to yourself if you're on Val Town Free. If you're on Val Town Pro , you can email anyone. Want to receive emails instead? Create an email handler val Basic usage import { email } from "https://esm.town/v/std/email"; await email({ subject: "New Ink & Switch Post!", text: "https://www.inkandswitch.com/embark/" }); subject The email subject line. It defaults to Message from @your_username on Val Town . to , cc , and bcc By default, the to field is set to the owner of the Val Town account that calls it. If you have Val Town Pro, you can send emails to anyone via the to , cc , and bcc fields. If you don't have Val Town Pro, you can only send emails to yourself, so leave those fields blank. from The from is limited to a few options: It defaults to notifications@val.town if you don't specify it. If you do specify it, it must be of the form: your_username.valname@valtown.email . replyTo replyTo accepts a string email or an object with strings for email and name (optional). This can be useful if you are sending emails to others with Val Town Pro. import { email } from "https://esm.town/v/std/email"; await email({ to: "someone_else@example.com", from: "your_username.valname@valtown.email", replyTo: "your_email@example.com", text: "these pretzels are making me thirsty", }); Attachments You can attach files to your emails by using the attachments field. Attachments need to be Base64 encoded, which is what the btoa method is doing in this example: import { email } from "https://esm.town/v/std/email"; export const stdEmailAttachmentExample = email({ attachments: [ { content: btoa("hello attachments!"), filename: "test.txt", type: "text", disposition: "attachment", }, ], }); Here's an example sending a PDF . Headers You can set custom headers in emails that you send: import { email } from "https://esm.town/v/std/email?v=13" console.log( await email({ text: "Hi", headers: { "X-Custom-Header": "xxx", }, }), ) This is also documented in our REST API , and supported in the SDK . πŸ“ Edit docs
7
std avatar
std
runVal
Script
An interactive, runnable TypeScript val by std
0
nbbaier avatar
nbbaier
cronLogger
Script
Log your cron evaluations to sqlite import { cronEvalLogger as logger } from "https://esm.town/v/nbbaier/cronLogger"; const run = async (interval: Interval) => { console.log("your code goes here"); }; export default logger(run);
0
stainless_em avatar
stainless_em
openapi_playground
HTTP
Forked from easrng/playground
0
partlysunny avatar
partlysunny
sqlite
Script
Forked from stevekrouse/sqlite
0
iamseeley avatar
iamseeley
api
Script
Forked from pomdtr/api
0
andreterron avatar
andreterron
sqlite_docs
Script
Forked from std/sqlite
0
boubou007 avatar
boubou007
sqlite
Script
Forked from stevekrouse/sqlite
0
nbbaier avatar
nbbaier
vt_backup_endpoint
HTTP
Forked from nbbaier/envVals
0
neverstew avatar
neverstew
cronEvalLogger
Script
Forked from nbbaier/cronLogger
0
stevekrouse avatar
stevekrouse
visionaryPeachAsp
HTTP
Forked from stevekrouse/socialDataProxy
0
shouser avatar
shouser
email
Script
Forked from std/email
0
std avatar
std
blob
Script
Blob Storage - Docs β†— Val Town comes with blob storage built-in. It allows for storing any data, like text, JSON, or images. You can access it via std/blob . Blob storage is scoped globally to your account. If you set a blob in one val, you can retrieve it by the same key in another val. It's backed by Cloudflare R2. Blob Admin Panels Blob Storage in Settings – built-into Val Town - list, download, delete blobs Blob Admin – search, view, edit, upload blobs – built in a val – easy to customize in Val Town! Usage Get JSON import { blob } from "https://esm.town/v/std/blob"; let blobDemo = await blob.getJSON("myKey"); console.log(blobDemo); // returns `undefined` if not found Set JSON import { blob } from "https://esm.town/v/std/blob"; await blob.setJSON("myKey", { hello: "world" }); List keys import { blob } from "https://esm.town/v/std/blob"; let allKeys = await blob.list(); console.log(allKeys); const appKeys = await blob.list("app_"); console.log(appKeys); // all keys that begin with `app_` Delete by key import { blob } from "https://esm.town/v/std/blob"; await blob.delete("myKey"); Examples Counter RSS Notifications (saving the last run time) Picture: Save & Read Error Handling blob.get can throw ValTownBlobNotFoundError Any method can throw ValTownBlobError for unexpected errors. Utilities Our Blob SDK also includes some utility functions to make working with blobs easier. Copy import { blob } from "https://esm.town/v/std/blob"; await blob.copy("myKey", "myKeyCopy"); Move import { blob } from "https://esm.town/v/std/blob"; await blob.move("myKey", "myKeyNew"); Lower-level API We provide access to the lower-level getter and setters, which are useful if you are storing non-JSON or binary data, need to stream in your response or request data, or do anything else lower-level. async get(key: string) : Retrieves a blob for a given key. async set(key: string, value: string | BodyInit) : Sets the blob value for a given key. See BodyInit . Limitations Blob-stored data counts towards your total Val Town storage – 10mb on the free plan and 1gb on pro. Check our pricing page to learn more. Keys for blobs can be up to 512 characters long. πŸ“ Edit docs
9
Madlean avatar
Madlean
sqlite
Script
Forked from stevekrouse/sqlite
0
zarutian avatar
zarutian
getMyValTownUserUUID
Script
// const VALTOWN_API_URL = "https://api.val.town/v1";
0
std avatar
std
openaiproxy
HTTP
OpenAI Proxy This OpenAI API proxy injects Val Town's API keys. For usage documentation, check out https://www.val.town/v/std/openai
1
Updated: January 24, 2024