211Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
212Start your response with a comment explaining how your approach will work, what libraries or
213API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
214the simplest way to achieve the goal, though you can add some inline comments to explain your
215reasoning (not for every line, but for major groups of lines). Don't use any environment variables
216unless strictly necessary, for example use APIs that don't require a key, prefer internal function
217imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
218functions where possible. Unless specified, don't add error handling,
219make sure that errors bubble up to the caller.
220Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
221not practical for the user's request (e.g. if they ask for a particular animated gif).
222If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
223explicitly specified otherwise. Use the current val name for the storage key, which you can get
224using the "pomdtr/extractValInfo" val, which you can call like this:
273Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
274Add comments at the top of the file explaining how your approach works, what libraries or
275API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
276the simplest way to achieve the goal, though you can add some inline comments to explain your
277reasoning (not for every line, but for major groups of lines). Don't use any environment variables
278unless strictly necessary, for example use APIs that don't require a key, prefer internal function
279imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
280functions where possible. Unless specified, don't add error handling,
281make sure that errors bubble up to the caller.
282Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
283not practical for the user's request (e.g. if they ask for a particular animated gif).
284If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
285explicitly specified otherwise. Use the current val name for the storage key, which you can get
286using the "pomdtr/extractValInfo" val, which you can call like this:
389\`\`\`
390
391### Lower-level API
392
393We do provide access to the lower-level getter and setters, which are useful if you are storing non-JSON or binary data, need to stream in your response or request data, or do anything else lower-level.
394
395- \`async get(key: string)\`: Retrieves a blob for a given key.
396- \`async set(key: string, value: string | BodyInit)\`: Sets the blob value for a given key. See [BodyInit](https://deno.land/api@v1.38.1?s=BodyInit).
397
398### Limitations
12041205const tempValName = `valle_tmp_${Math.random() * 10}`.replaceAll(".", "");
1206// Errors in running the val bubble up through this API, so ignore them.
1207await vt.vals.create({ name: tempValName, code: newCode, type: "http" as any, privacy: "unlisted" }).catch(
1208(error) => {
password_authREADME.md1 match
19```
2021If you want to use an [api token](https://www.val.town/settings/api) to authenticate:
2223```ts
personalDatamain.tsx1 match
80{
81"name": "Web Development",
82"keywords": ["HTML5", "CSS", "Tailwind CSS", "React", "Next.js", "Vite", "FastAPI", "Hono", "Framer Motion"]
83},
84{
getAllNotionDbRowsmain.tsx1 match
12return await axios({
13method: "POST",
14url: `https://api.notion.com/v1/databases/${databaseId}/query`,
15headers: {
16Authorization: `Bearer ${notionAccessToken}`,
nationalPeachPeacockmain.tsx1 match
45const DATABASE_ID = "519446a0d3ed47038fffd669b9ece770";
6const notion = new Client({ auth: process.env.NOTION_API_KEY });
78const intervalMapping = {
wetGrayQueleamain.tsx1 match
45const DATABASE_ID = "519446a0d3ed47038fffd669b9ece770";
6const notion = new Client({ auth: process.env.NOTION_API_KEY });
78const intervalMapping = {
dailyPeachSalmonmain.tsx1 match
45const DATABASE_ID = "519446a0d3ed47038fffd669b9ece770";
6const notion = new Client({ auth: process.env.NOTION_API_KEY });
78const intervalMapping = {
notionRecurringTasksmain.tsx1 match
45const DATABASE_ID = "519446a0d3ed47038fffd669b9ece770";
6const notion = new Client({ auth: process.env.NOTION_API_KEY });
78const intervalMapping = {
AlgoliaInstantSearchWebsitemain.tsx9 matches
2import { configure, hits, pagination, searchBox } from "https://esm.sh/instantsearch.js@4.49.1/es/widgets";
34function validateConfig(): { appId: string; apiKey: string } {
5const appId = Deno.env.get("ALGOLIA_APP_ID");
6const apiKey = Deno.env.get("ALGOLIA_SEARCH_API_KEY");
78if (!appId || !apiKey) {
9throw new Error("Algolia credentials are not properly set");
10}
1112return { appId, apiKey };
13}
1415function generateHtml(appId: string, apiKey: string): string {
16console.log("Generating HTML with App ID:", appId, "and API Key:", apiKey ? "exists" : "missing");
17return `
18<!DOCTYPE html>
67<script>
68console.log("Initializing Algolia search with App ID:", "${appId}");
69const searchClient = algoliasearch("${appId}", "${apiKey}");
7071const search = instantsearch({
124console.log("Received request:", request.url);
125try {
126const { appId, apiKey } = validateConfig();
127const html = generateHtml(appId, apiKey);
128console.log("Generated HTML, length:", html.length);
129return new Response(html, {
2import { configure, hits, pagination, searchBox } from "https://esm.sh/instantsearch.js@4.49.1/es/widgets";
34function validateConfig(): { appId: string; apiKey: string } {
5const appId = Deno.env.get("ALGOLIA_APP_ID");
6const apiKey = Deno.env.get("ALGOLIA_SEARCH_API_KEY");
78if (!appId || !apiKey) {
9throw new Error("Algolia credentials are not properly set");
10}
1112return { appId, apiKey };
13}
1415function generateHtml(appId: string, apiKey: string): string {
16console.log("Generating HTML with App ID:", appId, "and API Key:", apiKey ? "exists" : "missing");
17return `
18<!DOCTYPE html>
67<script>
68console.log("Initializing Algolia search with App ID:", "${appId}");
69const searchClient = algoliasearch("${appId}", "${apiKey}");
7071const search = instantsearch({
124console.log("Received request:", request.url);
125try {
126const { appId, apiKey } = validateConfig();
127const html = generateHtml(appId, apiKey);
128console.log("Generated HTML, length:", html.length);
129return new Response(html, {