1export async function sparql(query) {
2 const url = `https://query.wikidata.org/sparql?query=${encodeURIComponent(query)}`;
3 const res = await fetch(url, {
4 headers: {
5 "Accept": "application/sparql-results+json",
1import { fetchVerificationEmailHtml } from "https://esm.town/v/petermillspaugh/fetchVerificationEmailHtml";
2import { refreshVerificationToken } from "https://esm.town/v/petermillspaugh/refreshVerificationToken";
3import { sendVerificationEmail } from "https://esm.town/v/petermillspaugh/sendVerificationEmail";
23
24 // Lack of await is intentional: send optimistic success response, then send email and notify myself async
25 sendVerificationEmail({ emailAddress: email, html: fetchVerificationEmailHtml({ email, token }) });
26
27 return Response.json({ success: true, message: "Sent verification email." });
37 sendVerificationEmail({
38 emailAddress: email,
39 html: fetchVerificationEmailHtml({ email, token: newToken, reVerifying: true }),
40 });
41
77 });
78
79 return app.fetch(req);
80}
3let cache: [string, AuthTokens] | undefined;
4
5export function moduleFetch(input: RequestInfo | URL, init?: RequestInit | undefined): Promise<Response> {
6 const req = new Request(input, init);
7 let authTokens = Deno.env.get("DENO_AUTH_TOKENS");
19 }
20 }
21 return fetch(req);
22}
1export async function getCurrentWeather(latitude = 0, longitude = 0) {
2 const pointsResponse = await fetch(`https://api.weather.gov/points/${latitude},${longitude}`),
3 { properties: { forecastHourly } } = await pointsResponse.json(),
4 forecastResponse = await fetch(forecastHourly),
5 { properties: { periods } } = await forecastResponse.json();
6
3Reacquaint myself with how modern browsers deal with cross-origin cookies. Specifically, how aggressive does Safari limit them nowadays? (Answer: very aggressive, to the point of just disabling them.)
4
5This endpoint simply tries to assign a 28-day-from-now-expiring device cookie when requested, providing all of the obligatory-in-2024 cookie flags and headers to allow cross-origin support. You can request it from another origin in different browsers and inspect if cookies are sent back or not (either via `sendBeacon` or `fetch(..., {credentials: "include"})` or in the iframe browser preview below).
6
7Chrome and Firefox subsequently send back a persistent cookie; Safari does not. Edge probably does what Chrome does. I dunno what Braze does.
55});
56
57export default app.fetch;
67 fillBlank: FILL_BLANK,
68 quiz: QUIZ,
69 fetchHtml: (email: string, lesson: number) =>
70 generateLessonHtml({
71 email,
7});
8
9export default app.fetch;
32 });
33
34 return app.fetch(req);
35};
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export const createVal = async ({ code, token, name, privacy }: {
7 privacy?: "public" | "unlisted" | "private";
8}) => {
9 return fetchJSON("https://api.val.town/v1/vals", {
10 method: "post",
11 bearer: token,