Email218 words
email function in the standard library. Type Signature. Files triggered by Email receive an argument called Email that represents the email that was sent. Here’s an example: Example export async
Sections
team emails to Discord / Slack. Tip. Vals can send email, too! Using the email function in the standard library.
Type Signature
Type Signature. Files triggered by Email receive an argument called Email that represents the email that was sent. Here’s an example: Example export async function emailValHandler(email: Email) { console.log("Email received!",
Cron (Scheduled)258 words
morning. Crons can be configured with cron syntax, or simple intervals like “once an hour” Functions can run up to once every 15 minutes, or once a minute, with the
Sections
Cron (Scheduled)
morning. Crons can be configured with cron syntax, or simple intervals like “once an hour” Functions can run up to once every 15 minutes, or once a minute, with the
Type Signature
Type Signature. Crons take an Interval object as a parameter, and can return anything as a result. The return value is ignored. ExampleRun in Val Town ↗ export function cronValHandler(interval:
Send Discord message via webhook125 words
{ "Content-Type": "application/json", }, body: JSON.stringify({ content }), }); if (text.length) throw Error("Discord Webhook error: " + text); }; You can browse example usages of this function here. Example Integration.
Sections
Send Discord message via webhook
throw Error("Discord Webhook error: " + text); }; You can browse example usages of this function here.
Receiving a GitHub Webhook364 words
at the Recent Deliveries page of your webhook. Securing GitHub Webhooks. Once public, your val function will listen for any payload sent to its endpoint. For security reasons, you probably
Sections
Securing GitHub Webhooks
Once public, your val function will listen for any payload sent to its endpoint. For security reasons, you probably want to limit requests to those coming from GitHub. One method
RSS145 words
"https://esm.town/v/std/email?v=9"; import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems"; import { rssFeeds } from "https://esm.town/v/stevekrouse/rssFeeds"; export async function pollRSSFeeds({ lastRunAt }: Interval) { return Promise.all( Object.entries(rssFeeds).map(async ([name, url]) => { let items
Sections
Polling RSS
"https://esm.town/v/std/email?v=9"; import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems"; import { rssFeeds } from "https://esm.town/v/stevekrouse/rssFeeds"; export async function pollRSSFeeds({ lastRunAt }: Interval) { return Promise.all( Object.entries(rssFeeds).map(async ([name, url]) => { let items
Val Town Docs181 words
questions about this page. Val Town is a collaborative website to create and scale JavaScript functions. Create APIs, crons, store data – all from the browser, and deployed in miliseconds.
Sections
Val Town Docs
questions about this page. Val Town is a collaborative website to create and scale JavaScript functions. Create APIs, crons, store data – all from the browser, and deployed in miliseconds.
ORMs197 words
await db.select().from(kv).all(); console.log(sqliteDrizzleExample); Prisma. 🚫 Prisma isn’t supported in Val Town because it relies on functionality that only exists in a classic server environment. Sequelize. 🚫 Sequelize isn’t supported in
Sections
Prisma
Prisma. 🚫 Prisma isn’t supported in Val Town because it relies on functionality that only exists in a classic server environment.
Importing664 words
mind, and won’t work with Deno. While Deno implements most of the functionality of Node.js and some of the functionality of browsers - so many modules will “just work” in
Sections
Look for Deno compatibility
mind, and won’t work with Deno. While Deno implements most of the functionality of Node.js and some of the functionality of browsers - so many modules will “just work” in
Stripe714 words
@ts-ignore. import { Stripe } from "npm:stripe"; const stripe = new Stripe(Deno.env.get("STRIPE_TEST_API_KEY")); export default async function (req: Request): Promise<Response> { const url = new URL(req.url); if (url.pathname === "/") {
Sections
Stripe Checkout
@ts-ignore. import { Stripe } from "npm:stripe"; const stripe = new Stripe(Deno.env.get("STRIPE_TEST_API_KEY")); export default async function (req: Request): Promise<Response> { const url = new URL(req.url); if (url.pathname === "/") {
Example Val Town Stripe Webhook
from "npm:stripe"; const stripe = new Stripe( Deno.env.get("stripe_sk_customer_readonly") as string, { apiVersion: "2020-08-27", } ); function getStripeCustomer(customerId: string) { return stripe.customers.retrieve(customerId); } export let newStripeEvent = async (req: Request) =>
Upgrade Guide: Safer Val Scopes333 words
is deprecated and we now use blob storage with our std/blob library instead. The equivalent function to std.set() is blob.setJSON(). // Using std/set. import { set } from "https://esm.town/v/std/set"; set("createdAt",
Sections
Use Blob Storage Instead (recommended)
Use Blob Storage Instead (recommended). Std/set is deprecated and we now use blob storage with our std/blob library instead. The equivalent function to std.set() is blob.setJSON(). // Using std/set. import