1// import { Request, Response } from "./node_modules/express/index.js";
2export default async function(req: Request): Promise<Response> {
3 console.log("Request received:", req);
4
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}
5import { refs } from "https://esm.town/v/stevekrouse/refs?v=11";
6
7type CronFunction = (interval: Interval) => Promise<void>;
8
9export const cronEvalLogger = (cron: CronFunction): CronFunction => {
10 let interval: Interval;
11 const cronProxy = new Proxy(cron, {
6);
7
8export async function uptimeCheck(url: string) {
9 let reason: string, status: number, end: number;
10 let ok = true;
9Plain, brutalist, no bloat chess. Every page is only html and css. Every chess move is made by clicking a link. Send a link to your friend and they'll send you one back to make your move. No silly animations or slick interactivity to trip up your gameplay. When Google indexes this site will we successfully compute all possible chess moves?
10
11Functionality is quite limited, and things might be broken. Please let me know if you find bugs!
12
13Inspired by [this HN discussion](https://news.ycombinator.com/item?id=39456467) about sites that have all possible game states of tic-tac-toe.
23};
24
25export default async function(req: Request): Promise<Response> {
26 const pageContent = renderToString(
27 <html>
63});
64
65async function loadTests(): Promise<TestType[]> {
66 const query = `https://esm.town/v/${author}/test_explorer`;
67 const { data: vals } = await api(`/v1/search/vals?query=${query}`, { authenticated: true });
90}
91
92async function loadHistory(): Promise<HistoryEntry[]> {
93 try {
94 const entries = await readHistory();
62});
63
64async function loadTests(): Promise<TestType[]> {
65 const query = `https://esm.town/v/${author}/test_explorer`;
66 const { data: vals } = await api(`/v1/search/vals?query=${query}`, { authenticated: true });
89}
90
91async function loadHistory(): Promise<HistoryEntry[]> {
92 try {
93 const entries = await readHistory();
17
18
19async function streamToBuffer(stream) {
20 const chunks = [];
21 const reader = stream.getReader();
32}
33
34async function detectFileType(buffer) {
35 const type = await fileTypeFromBuffer(buffer);
36 // return type ? type.mime : 'unknown';
42
43
44export async function get(key, c) {
45 let result = await blobby.get(key);
46 // console.log('raw result for key:', result, typeof result);
185 newKeyName: '',
186
187 init: async function() {
188 console.log('blobby:', this.blobby);
189 },
4import { Hono } from "npm:hono";
5
6function setupTable() {
7 return sqlite.execute(`create table if not exists counter_town (
8 time timestamp default current_timestamp,
21// TODO - we should probably not expose this to our users
22// this rewrite removes that and stores the url underneath
23function removeCustomDomainRewriter(req) {
24 const servedFor = req.headers.get("x-served-for");
25 return req.url.replace("saascustomdomains.val.run", servedFor);
26}
27
28function countRequest(req: Request) {
29 console.log(req);
30 return sqlite.execute({
41}
42
43export function counterTownMiddleware(handler) {
44 return async function(req: Request) {
45 // don't await this so it doesn't add to the timing
46 countRequest(req).catch(e => console.error(e));
125
126// zipped execute
127async function execute(sql) {
128 const results = await sqlite.execute(sql);
129 return results.rows.map(row =>