Public
HTTP (deprecated)
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

User with Most Vals

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { zip } from "https://esm.town/v/pomdtr/sql";
import { db } from "https://esm.town/v/sqlite/db?v=9";
import { renderTable } from "npm:console-table-printer";
import stripAnsi from "npm:strip-ansi";
export default async function() {
const res = await db.execute(
"SELECT author_username, COUNT(*) AS val_count FROM vals GROUP BY author_username ORDER BY 2 DESC LIMIT 10",
);
const table = stripAnsi(renderTable(zip(res)));
const resp = await fetch("https://sourcecodeshots.com/api/image", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(
{ code: table, language: "text" },
),
});
if (!resp.ok) {
throw new Error(await resp.text());
}
return new Response(resp.body, {
headers: {
"Content-Type": "image/png",
"Cache-Control": "fsjkdfdsjkj"
},
});
}
sqlite-leaderboard.web.val.run
April 5, 2024