HonoDenoVite2server.tsx3 matches
30const projectVal = parseProject(import.meta.url);
3132// Create a main Hono app that will handle both API routes and proxy to Vite
33const mainApp = new Hono();
3435// Mount the Hono app from src/index.tsx to handle API routes
36mainApp.route("/api", app);
3738// For all other routes, use the Vite proxy
HonoDenoViteindex.tsx1 match
3const app = new Hono();
45const routes = app.get("/api/clock", (c) => {
6return c.json({
7time: new Date().toLocaleTimeString(),
HonoDenoViteclient.tsx2 matches
12<h2>Example of useState()</h2>
13<Counter />
14<h2>Example of API fetch()</h2>
15<ClockButton />
16</>
3132const handleClick = async () => {
33const response = await client.api.clock.$get();
34const data = await response.json();
35const headers = Array.from(response.headers.entries()).reduce<
NowPlayingGrabbermain.tsx2 matches
2import querystring from "npm:querystring";
34const NOW_PLAYING_ENDPOINT = "https://api.spotify.com/v1/me/player/currently-playing";
5const TOKEN_ENDPOINT = "https://accounts.spotify.com/api/token";
67const client_id = Deno.env.get("spotify_client_id");
146export default async function(request, env, ctx) {
147const url = new URL(request.url);
148if (!url.pathname.startsWith("/api")) {
149return new Response("welcome", {
150headers: { "content-type": "text/html" },
432433function ProductCarousel({ children }: { children: React.ReactNode }) {
434const [emblaRef, emblaApi] = useEmblaCarousel({
435axis: "x",
436loop: false,
457458useEffect(() => {
459if (emblaApi) {
460scrollByRef.current = (delta: number) => {
461isScrollingRef.current = true;
462const scrollResult = emblaApi.scrollTo(emblaApi.selectedScrollSnap() + Math.sign(delta));
463464if (scrollResult && typeof scrollResult.then === "function") {
471};
472473const rootNode = emblaApi.rootNode();
474rootNode.addEventListener("wheel", onWheel, { passive: false });
475rootNode.style.overflowY = "auto";
480};
481}
482}, [emblaApi, onWheel]);
483484return (
682683const script = document.createElement("script");
684script.src = `https://maps.googleapis.com/maps/api/js?key=AIzaSyAOtUMb5jLTjTVM7iKzIx2SJ3HgMKNcM7U&libraries=places`;
685script.async = true;
686script.defer = true;
806// Reverse geocode the coordinates to get an address
807const response = await fetch(
808`https://maps.googleapis.com/maps/api/geocode/json?latlng=${position.coords.latitude},${position.coords.longitude}&key=AIzaSyAOtUMb5jLTjTVM7iKzIx2SJ3HgMKNcM7U`,
809);
810const data = await response.json();
562}
563564const apiRequestBody: any = { model, messages: messagesPayload };
565if (typeof params.temperature === "number") apiRequestBody.temperature = params.temperature;
566if (typeof params.max_tokens === "number" && params.max_tokens > 0)
567apiRequestBody.max_tokens = Math.floor(params.max_tokens);
568569log("INFO", "OpenAiCallTool", "Making OpenAI chat completion call.", {
576577try {
578const completion = await openaiClient.chat.completions.create(apiRequestBody);
579if (!completion?.choices?.length) {
580log("WARN", "OpenAiCallTool", "OpenAI response empty/unexpected.", { response: completion });
583return { mandateId, correlationId: taskId, payload: { result: completion } };
584} catch (e: any) {
585log("ERROR", "OpenAiCallTool", "OpenAI API call failed.", e);
586const errMsg = e.response?.data?.error?.message || e.error?.message || e.message || "Unknown OpenAI API error";
587return { mandateId, correlationId: taskId, payload: { result: null }, error: errMsg };
588}
701const { mandateId, taskId, payload } = input;
702const { log } = context;
703log("INFO", "ScrapeEmails", `Scraping emails for ${payload.businesses?.length ?? 0} sites.`);
704705if (!payload?.businesses || !Array.isArray(payload.businesses)) {
753await delay(WEBSITE_VISIT_DELAY_MS);
754}
755log("SUCCESS", "ScrapeEmails", `Scraping done. Found emails for ${foundLeads.length} leads.`);
756return { mandateId, correlationId: taskId, payload: { leads: foundLeads } };
757}
810} catch (error: any) {
811log("ERROR", "DraftEmails", `Failed for ${lead.name}: ${error.message}`, error);
812finalLeads.push({ ...lead, draftedEmail: "[OpenAI API call failed]" });
813}
814await delay(300); // Small delay between OpenAI calls
1117<body><h1>Superpowered Agent Platform - Lead Gen Demo</h1>
1118<p>Runs <code>leadGenWorkflowV1</code>. See <a href="/">Original V3 Demo</a>.</p>
1119<p><strong>Note:</strong> Google Search is simulated. Scraping is basic.</p>
1120<form id="leadGenForm">
1121<label for="searchQuery">Search Query (Required):</label><input type="text" id="searchQuery" name="searchQuery" required value="dentists in Los Angeles">
61const fetchStories = async () => {
62try {
63const response = await fetch("/api/stories");
64if (!response.ok) throw new Error("Failed to fetch dates");
65const data = await response.json();
75try {
76dispatch({ type: "loading", value: true });
77const response = await fetch(`/api/comments?query=${encodeURIComponent(query)}&story=${story}&page=${page}`);
78if (!response.ok) throw new Error("Failed to fetch comments");
79const data = await response.json();
364export default async function(req: Request): Promise<Response> {
365const url = new URL(req.url);
366if (url.pathname === "/api/stories") {
367const storySearch = await hnSearch({
368search_by_date: true,
385}
386387if (url.pathname === "/api/comments") {
388const params = url.searchParams;
389const query = params.get("query") || "";
440441function ProductCarousel({ children }: { children: React.ReactNode }) {
442const [emblaRef, emblaApi] = useEmblaCarousel({
443axis: "x",
444loop: false,
465466useEffect(() => {
467if (emblaApi) {
468scrollByRef.current = (delta: number) => {
469isScrollingRef.current = true;
470const scrollResult = emblaApi.scrollTo(emblaApi.selectedScrollSnap() + Math.sign(delta));
471472if (scrollResult && typeof scrollResult.then === "function") {
479};
480481const rootNode = emblaApi.rootNode();
482rootNode.addEventListener("wheel", onWheel, { passive: false });
483rootNode.style.overflowY = "auto";
488};
489}
490}, [emblaApi, onWheel]);
491492return (
690691const script = document.createElement("script");
692script.src = `https://maps.googleapis.com/maps/api/js?key=AIzaSyAOtUMb5jLTjTVM7iKzIx2SJ3HgMKNcM7U&libraries=places`;
693script.async = true;
694script.defer = true;
814// Reverse geocode the coordinates to get an address
815const response = await fetch(
816`https://maps.googleapis.com/maps/api/geocode/json?latlng=${position.coords.latitude},${position.coords.longitude}&key=AIzaSyAOtUMb5jLTjTVM7iKzIx2SJ3HgMKNcM7U`,
817);
818const data = await response.json();
1184});
11851186app.post("/api", async (c) => {
1187console.log(c.req.body);
1188return c.json({ ok: true });
stevensDemoREADME.md1 match
53You'll need to set up some environment variables to make it run.
5455- `ANTHROPIC_API_KEY` for LLM calls
56- You'll need to follow [these instructions](https://docs.val.town/integrations/telegram/) to make a telegram bot, and set `TELEGRAM_TOKEN`. You'll also need to get a `TELEGRAM_CHAT_ID` in order to have the bot remember chat contents.
57- For the Google Calendar integration you'll need `GOOGLE_CALENDAR_ACCOUNT_ID` and `GOOGLE_CALENDAR_CALENDAR_ID`. See [these instuctions](https://www.val.town/v/stevekrouse/pipedream) for details.