4const app = new Hono();
5
6const WEATHER_API_KEY = Deno.env.get('WEATHER_API_KEY'); // Replace with your actual weather API key
7const BASE_URL = "https://api.openweathermap.org/data/2.5/weather";
8
9app.get("/", async (c) => {
10 const response = await fetch(
11 `${BASE_URL}?q=Brooklyn&units=metric&appid=${WEATHER_API_KEY}`
12 );
13 const weatherData = await response.json();
14}): Promise<TweetResult[]> {
15 const res = await twitterJSON({
16 url: `https://api.twitter.com/2/tweets/search/recent?query=${await searchParams(
17 {
18 query,
1import { inTheBackground } from "https://esm.town/v/neverstew/inTheBackground";
2import { API_URL } from "https://esm.town/v/std/API_URL?v=5";
3import { sqlite } from "https://esm.town/v/std/sqlite?v=6";
4import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=45";
26 headers["Authorization"] = `Bearer ${token}`;
27 }
28 const { id } = await fetchJSON(`${API_URL}/v1/alias/${userHandle}/${valName}`, { headers });
29
30 const table_name = "cron_evals";
7
8export default async function(req: Request): Promise<Response> {
9 // from https://automerge.org/automerge/api-docs/js/
10 type DocType = { ideas: Array<automerge.Text> };
11
1Migrated from folder: External_APIs/browserbase/browserbase_google_concerts
1Migrated from folder: External_APIs/browserbase/browserbase
1/** @jsxImportSource npm:hono/jsx */
2
3import { api } from "https://esm.town/v/pomdtr/api";
4import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
5import { Island } from "https://esm.town/v/pomdtr/hono_island";
17const router = new Hono();
18
19const me = await api("/v1/me", { authenticated: true });
20const author = me.username;
21
57});
58
59router.post("/api/refresh", async () => {
60 const tests = await loadTests();
61
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 });
68 const tests = {};
69 for (const val of vals) {
103}
104
105router.post("/api/run", async (c) => {
106 const body = await c.req.json();
107 try {
1/** @jsxImportSource npm:hono/jsx */
2
3import { api } from "https://esm.town/v/pomdtr/api";
4import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo";
5import { Island } from "https://esm.town/v/pomdtr/hono_island";
56});
57
58router.post("/api/refresh", async () => {
59 const tests = await loadTests();
60
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 });
67 const tests = {};
68 for (const val of vals) {
102}
103
104router.post("/api/run", async (c) => {
105 const body = await c.req.json();
106 try {
33
34In order to define a test, the user need to import the Test class from `https://val.town/v/<account>/Test`.
35So we can use the api to search for vals containing the `https://val.town/v/<account>/Test` string to locate the vals containing tests.
36
37Next, we need to extract the tests from the val exports. We use `exported instanceof Test` to filter them (at some point we will probably use static analysis for this).
1# Val Town REST API TypeScript SDK Demos
2
3This val demonstrates basic usage of the the Val Town JS/TS SDK.
5You can fork this val to your account to quickly try it out.
6
7Authentication is automatically set by the `VAL_TOWN_API_KEY` environment
8variable, which is automatically set within Val Town. You can control the
9API scopes of that key in your val's settings page.
10
11* [Learn more](https://docs.val.town/sdk/)
12* [Reference docs](https://github.com/val-town/sdk/blob/main/api.md)
13
14Migrated from folder: Archive/demoSDK