You can do a lot with Val Town
Cron jobs, creating REST APIs, receiving and sending emails, storing data in SQLite, receiving webhooks, using modules from NPM, generating images and PDFs, scraping webpages, checking prices…
Cron jobs
Schedule any function in one click. Use the full power of cron syntax or a simple interval to run vals every hour, at a particular time of day, or whatever you can dream up.
stevekrouse/trackIphoneTradein
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import cheerio from "npm:cheerio@1.0.0-rc.12";
export const trackIphoneTradein = (async () => {
const page = await fetch(
"https://www.apple.com/shop/" +
"browse/overlay/tradein_landing/iphone_values",
).then((r) => r.text());
const $ = cheerio.load(page);
const rows = $("tr").map((row, elem) => {
const [name, val] = $(elem)
.find("td")
.map((idx, elem) => $(elem).text())
.toArray();
return { name, val };
}).toArray().filter((row) => row.name && row.val);
stevekrouse.iphoneTradeInValues.push({
date: new Date().toISOString(),
rows,
});
return rows;
});
Create APIs
Respond to HTTP requests, build websites, APIs, and more with Request & Response objects. Compatible with modern web frameworks like Hono and itty-router. Support for building HTML with JSX syntax.
tmcw/endpoint
1
2
3
4
5
6
7
8
9
10
11
12
13
/** @jsxImportSource npm:hono/jsx */
import { Hono } from "npm:hono@3.8.1";
import {
jsxRenderer,
useRequestContext
} from "npm:hono@3.8.1/jsx-renderer";
export const endpoint = (req: Request) => {
const app = new Hono();
app.get("/", (c) =>
c.render(<div>Hello, world!</div>));
return app.fetch(req);
};
https://tmcw-endpoint.web.val.run
Hello, world!
Email yourself
Send yourself an email as easily as you log to the console.
stevekrouse/umbrellaReminder
1
2
3
4
5
6
7
8
9
10
11
import { email } from "https://v3.module.town/v/std/email?v=7";
import { fetchJSON } from "https://v3.module.town/v/stevekrouse/fetchJSON";
import { umbrellaNeeded } from "https://v3.module.town/v/stevekrouse/umbrellaNeeded";
export const umbrellaReminder = async () => {
if (await umbrellaNeeded("brooklyn")) {
await email({
subject: "☔️ Carry an umbrella today!"
});
}
};
From:notifications@val.town
To:me@gmail.com
Subject: ☔️ Carry an umbrella today!
This is an email notification from Val Town: you can customize everything about it.
Share & learn in a community
Val Town isn't just a place to write code: it's a community to share ideas and build on each other’s inspiration.
CommentsLikesForksCommunity Discord
stevekrouse/gettingStarted
1
2
3
export const myFirstFunction = (a, b) => {
return a + b;
};
10 likes
2 new comments
Import from npm and deno
Thousands of NPM modules are supported, along with Deno modules. No installation required - just import and it's there.
lodashHonocheeriozodmarkedremarkchalkelysiamomentopenaiunderscored3luxondate-fnsthousands more
Val Town is a social website to write and run code.
Vals are small JavaScript or TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.