1import { html } from "https://esm.town/v/stevekrouse/html";
2
3export default async function(req: Request): Promise<Response> {
4 // return new Response("<h1>Hello FRC!</h1>", { headers: {
5 // "Content-Type": "text/html"
11}
12
13export function updateValByID({ token, valId, code, name, readme, privacy }: UpdateValArgs): Promise<any> {
14 const body: Record<string, unknown> = {
15 token,
7}
8
9export function updateValByName({ token, code, name }: UpdateValArgs): Promise<any> {
10 const body: Record<string, unknown> = {
11 token,
1# Fetch Paginated Data
2
3This val exports a function that loops through paginated API responses and returns the combined data as an array. It expects pagination with `next` and there to be a `data` property in the API response. This conforms to the Val Town API, so this function is useful when fetching paginated Val Town API responses for creating custom folders in [pomdtr's vscode extension](https://github.com/pomdtr/valtown-vscode).
4
5Usage:
1# Return a paginated response
2
3A helper function to take an array and return a paginated response. This is useful when defining one's own folders for [pomdtr's vscode extension](https://github.com/pomdtr/valtown-vscode).
4
5Usage:
8const data = [...]
9
10export default async function(req: Request): Promise<Response> {
11 return paginatedResponse(req, data);
12}
1import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
2
3export default async function(interval: Interval) {
4 const versions = await fetch("https://www.figma.com/api/plugins/1323092380415927575/versions").then(r => r.json());
5 const { install_count, like_count, view_count } = versions.meta.plugin;
3import { testEmails } from "https://esm.town/v/stevekrouse/testEmails";
4
5export async function testEmail2(e: Email) {
6 await set("testEmails", [...testEmails, {
7 ...e,
2import { blob } from "https://esm.town/v/std/blob?v=10";
3
4export async function sqlite_admin_tables() {
5 let blobs = await blob.list();
6 return (
1## Create an API from a [lowdb blob](https://www.val.town/v/pomdtr/lowdb)
2
3This val exports a function that takes a lowdb instance and returns a [Hono](https://hono.dev) router that can be used to interact with the data. This is the beginning of an implementation of something like [json-server](https://github.com/typicode/json-server) for Val Town.
4
5The resulting server also comes with a frontend at `/`. The code for the frontend can be found [here](https://www.val.town/v/nbbaier/dbToAPIFrontend).
1export const str = "hello world";
2
3export default function handler(request: Request) {
4 return Response.json({ ok: true });
5}