Search

expressHTMLExample2
@henrik
// View at https://api.val.town/express/@stevekrouse.expressHTMLExample?name=Steve
Script
import { mails } from "https://esm.town/v/henrik/mails";
// View at https://api.val.town/express/@stevekrouse.expressHTMLExample?name=Steve
export async function expressHTMLExample2(
req: express.Request,
res: express.Response
preactTest
@tmcw
An interactive, runnable TypeScript val by tmcw
Script
"https://npm.reversehttp.com/preact,htm,preact/hooks,preact-render-to-string"
const html = htm.bind(h);
function Component() {
const [count, setCount] = useState(0);
return html`<div class="foo">${count}</div>`;

likes
@neverstew
An interactive, runnable TypeScript val by neverstew
Script
import { searchParams } from "https://esm.town/v/stevekrouse/searchParams?v=9";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export function likes({ token, offset, limit }: {
token: string;
offset?: number;
UserSpecificResource
@rozek
Sometimes you want a val to be public (e.g., to give others the chance to inspect and fork it) but not to be callable by everybody (e.g., because you are accessing some resources which are rate limited or expensive) The simplest approach to meet both requirements is to require an authorization of type "Bearer" with a (random) token that is stored in a Val.Town environment variable. Such variables are specific to the owner of a val and - since the val is running on the server - cannot be inspected be the caller. As a consequence, only clients knowing the correct token can run the val, but everybody can inspect and fork it in order to use the val with his/her own environment setting. To experiment with this val, please fork it and define an environment variable called "UserSpecificResource" with whatever you want to use as an access token (e.g., a UUID or a random number) Some tests can be found in val UserSpecificResource_Test
HTTP
export default async function Handler (Request:Request):Promise<Response> {
const AccessToken = Deno.env.get('UserSpecificResource')
if (AccessToken == null) {
turquoisePiranha
@hmy
An interactive, runnable TypeScript val by hmy
HTTP
export default async function (req: Request): Promise<Response> {
return Response.json({ ok: true })
sqlite
@std
SQLite - Docs โ SQLite is a lightweight, standard database. Every Val Town account comes with its own private SQLite database that is accessible from any of your vals via std/sqlite . Val Town SQLite is powered by Turso . Usage Migrations ORMs We recommend these admin data viewers for managing your database โ viewing or editing data or your database table schema: Outerbase Studio (recommended) - formely known as LibSQL Studio โ see instructions here SQLite Explorer (built in Val Town) Limits You can store 10mb on the free plan and up to 1gb on the paid plan. Contact us if you need more space. ๐ Edit docs
Script
batch,
// Functions
async function execute(statement: InStatement): Promise<ResultSet> {
const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
return res.json();
async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
return res.json();
function createResError(body: string) {
try {
* The types are currently shown for types declared in a SQL table. For
* column types of function calls, for example, an empty string is
* returned.
add_to_habitify_from_todoist_w_ai
@nerdymomocat
// if you added new items to habitify after running this script
Cron
import OpenAI from "npm:openai";
const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
const oai = new OpenAI({
apiKey: OPENAI_API_KEY ?? undefined,
function getHabitifyAreaName(section_id) {
function convertDateObject(due) {
function convertToISOWithOffset(datetimeStr, timezoneStr) {
async function getCommentsForTask(taskId) {
async function resizeAndConvertImage(imageBuffer) {
async function downloadImage(url) {
musicalInstrumentIdentification
@uday_8897
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
</div>
function App() {
const [recording, setRecording] = useState(null);
const audioChunksRef = useRef([]);
// Audio Recording Functions
const startRecording = async () => {
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(
renderResume
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
export function renderResume({
resumeDetails,
theme,
cleanup
@websandbox
An interactive, runnable TypeScript val by websandbox
Cron
import { blob } from "https://esm.town/v/std/blob?v=11";
import { EXPIRY } from "https://esm.town/v/websandbox/config";
export default async function(interval: Interval) {
for (const b of await blob.list("play_")) {
if ((new Date(b.lastModified).valueOf() + EXPIRY) < Date.now()) {
valentine
@sapnai
Hello!!!
HTTP
"Pretty please?~ ๐ฅบ๐ฅบ๐ฅบ",
function App() {
const [noClicks, setNoClicks] = useState(0);
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(
linkInBioTemplate
@gigmx
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request) {
return new Response(
renderToString(
<script dangerouslySetInnerHTML={{
__html: `
document.addEventListener('DOMContentLoaded', function() {
const catChat = document.querySelector("#cat-chat");
if (catChat) {

passkey_script
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
const _logEl = document.getElementById("logs");
function log(message) {
console.log(message);
const _statusEl = document.getElementById("status");
function status(message) {
_statusEl.hidden = false;
return message;
async function postJson(url, body?) {
return await fetch(url, {
}).then((r) => (r.ok ? r.json() : r.text()));
async function handleRegister() {
const username = document.getElementById("name").value;
.catch(log);
async function startAuth(options, conditional) {
await SimpleWebAuthnBrowser.startAuthentication(options, conditional)
return await startAuth(options, true);
async function handleLogin() {
const username = document.getElementById("name").value;
await loginOptions.then(async (options) => await startAuth(options, false));
async function handleLogout() {
await postJson("/logout");
cs_1200
@emily_messenger
// Fetches a random joke.
Script
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
val_dO1pTtU7X9
@dhvanil
An interactive, runnable TypeScript val by dhvanil
Script
export default async function handler(req) {
try {
const result = await (async () => {
function isPrime(num) {
if (num <= 1) return false;
return true;
function findLowestThreeDigitPrime() {
for (let num = 100; num < 1000; num++) {