4
51. Sign up for [Cerebras](https://cloud.cerebras.ai/)
62. Get a Cerebras API Key
73. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
8
9# Todos
9const STARTER_PROMPTS = [
10 "todo list app persisted in local storage",
11 "weather app using open-meteo API",
12 "interactive markdown editor with live preview",
13 "pomodoro timer with sound notifications",
1# Framer Fetch: Basic
2
3A basic example of an API endpoint to use with Framer Fetch. CORS headers are permissive by default on Val Town, so no need to set them.
2import { Parser } from "npm:xml2js";
3
4const apiBase = "https://data.rijksmuseum.nl/";
5const resolverBase = "https://id.rijksmuseum.nl/";
6
18 manifest.setMetadata(metadata);
19 manifest.setSeeAlso([{
20 id: apiBase + id + "?_profile=la-framed",
21 type: "Dataset",
22 label: { "en": ["Linked Art Framed"] },
51
52function getImageInformation(record: any) {
53 const imageApiEndpoint = record?.["rdf:RDF"]?.["svcs:Service"]?.[0]?.$?.["rdf:about"];
54 if (imageApiEndpoint) {
55 return fetch(imageApiEndpoint)
56 .then(resp => resp.json())
57 .catch((err) => console.log(`Error fetching Image Information from ${imageApiEndpoint}`, err));
58 } else return null;
59}
147 ["Accept", "application/rdf+xml"],
148 ]);
149 const url = new URL(apiBase + id);
150 const parser = new Parser();
151 return fetch(url, { headers })
8import { Wide } from 'https://esm.town/v/maxm/wide';
9
10// Use your Val Town API Token to create a session
11const wide = new Wide(await ValSession.new(Deno.env.get("valtown")))
12
1import { ValSession } from "https://esm.town/v/maxm/valSession";
2// import type { TSearchFilter, WideApi } from "https://esm.town/v/maxm/wideApi";
3type WideApi = any;
4type TSearchFilter = any;
5import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
7
8const { htmlUrl } = extractValInfo(import.meta.url);
9const _client = hc<WideApi>("https://maxm-wideapi.web.val.run/");
10
11export class Wide {
14 constructor(sessionToken: string) {
15 // TODO: can we use a global client?
16 this.#client = hc<WideApi>("https://maxm-wideapi.web.val.run/");
17 this.#sessionToken = sessionToken;
18 }
75
76export default async function(req: Request): Promise<Response> {
77 // Use your Val Town API Token to create a session
78 const wide = new Wide(await ValSession.new(Deno.env.get("valtown")));
79 await wide.write([{
98 <script>hljs.highlightAll();</script>
99 <style>
100 @import url('https://fonts.googleapis.com/css2?family=Kumbh+Sans:wght@900&family=Roboto+Mono:wght@400;700&display=swap');
101
102 * {
196import { Wide } from 'https://esm.town/v/maxm/wide';
197
198// Use your Val Town API Token to create a session
199const wide = new Wide(await ValSession.new(Deno.env.get("valtown")))
200
4
51. Sign up for [Cerebras](https://cloud.cerebras.ai/)
62. Get a Cerebras API Key
73. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
8
9# Todos
9const STARTER_PROMPTS = [
10 "todo list app persisted in local storage",
11 "weather app using open-meteo API",
12 "interactive markdown editor with live preview",
13 "pomodoro timer with sound notifications",
7## Getting Started
8To run Slack Scout, you’ll need a
9- Browserbase API key
10- Slack Webhook URL: setup [here](https://docs.val.town/integrations/slack/send-messages-to-slack/)
11- Twitter Developer API key
12
13### Browserbase
19### Twitter
20
21We’ve decided to use the Twitter API to include Twitter post results. It costs $100 / month to have a Basic Twitter Developer account. _If you decide to use Browserbase, we can lend our token. Comment below for access._
22
23Once you have the `SLACK_WEBHOOK_URL`, `BROWSERBASE_API_KEY`, and `TWITTER_BEARER_TOKEN`, input all of these as [Val Town Environment Variables](https://www.val.town/settings/environment-variables).
24
25---
54 query: topic,
55 pages: 2,
56 apiKey: Deno.env.get("BROWSERBASE_API_KEY") ?? "",
57 });
58}
63 maxResults: 10,
64 daysBack: 1,
65 apiKey: Deno.env.get("TWITTER_BEARER_TOKEN") ?? "",
66 });
67}
98
99 if (!response.ok) {
100 throw new Error(`Slack API error: ${response.status} ${response.statusText}`);
101 }
102