hellnomain.tsx.tsx2 matches
1314const data = await response.json();
15console.log("API Response:", data);
16} catch (error) {
17console.error("Error fetching API:", error);
18}
19}
1// superpowered_agent_platform_vNext_client_orchestrated.ts
2// Server-side: Exposes tools and custom functions as individual API endpoints.
3// Client-side: Orchestrates calls to these endpoints based on an editable JSON workflow.
45// --- COMMON TYPES (can be shared or duplicated between client/server for clarity in this example) ---
6interface ApiRequest<T = any> {
7workflowInstanceId: string; // Generated by client for a particular workflow run
8stepId: string; // ID of the step being executed
11}
1213interface ApiResponse<T = any> {
14workflowInstanceId: string;
15stepId: string;
171});
172try {
173const openai = new OpenAI(); // Assumes OPENAI_API_KEY is in environment
174const completion = await openai.chat.completions.create({
175model,
183return completion;
184} catch (e: any) {
185logger.log("ERROR", "OpenAI API call failed.", e);
186throw e;
187}
577}
578579if (req.method !== "POST" || pathSegments[0] !== "api") {
580return new Response("Not Found. API endpoints are under /api/ and expect POST.", { status: 404 });
581}
582583let reqBody: ApiRequest;
584try {
585reqBody = await req.json();
645}
646647const apiResponse: ApiResponse = {
648workflowInstanceId,
649stepId,
653};
654655return Response.json(apiResponse, { status: errorMsg ? 500 : 200 });
656}
657767{
768"id": "validate",
769"endpoint": "/api/custom/validate_data",
770"description": "Validate raw data",
771"inputs": { "data": "{{load_data.rawData}}" },
774{
775"id": "clean_petal_width_llm",
776"endpoint": "/api/tools/openai_call",
777"description": "LLM cleaning for 'petal.width'",
778"inputs": {
796{
797"id": "transform_features",
798"endpoint": "/api/tools/run_script",
799"description": "Create new feature 'petal_area'",
800"inputs": {
807{
808"id": "summarize",
809"endpoint": "/api/custom/generate_summary_stats",
810"description": "Generate summary statistics on transformed data",
811"inputs": { "data": "{{transform_features.transformedData}}" },
815{
816"id": "insights_llm",
817"endpoint": "/api/tools/openai_call",
818"description": "Get LLM insights on summary",
819"inputs": {
829{
830"id": "visualize_petal_area",
831"endpoint": "/api/custom/generate_chart_config",
832"description": "Generate bar chart for petal_area by species",
833"inputs": {
1184}
1185} else {
1186const apiRequest = {
1187workflowInstanceId,
1188stepId: step.id,
1192method: 'POST',
1193headers: { 'Content-Type': 'application/json' },
1194body: JSON.stringify(apiRequest)
1195});
1196
1197const apiResponse = await response.json();
1198if (apiResponse.logs) {
1199apiResponse.logs.forEach(log => appendLog(log));
1200stepOutputs[step.id].logs = (stepOutputs[step.id].logs || []).concat(apiResponse.logs);
1201}
12021203if (!response.ok || apiResponse.error) {
1204throw new Error(apiResponse.error || \`API request for \${step.endpoint} failed with status \${response.status}\`);
1205}
1206rawResultPayload = apiResponse.payload;
1207}
1208
HonoDenoVite2README.md11 matches
1# Vite + Deno + React + TypeScript + Hono + Val Town
23A Vite project running on Val Town with Hono integration. The `server.tsx` serves the project and handles API routes using Hono while proxying frontend requests to the Vite development server. If you make any edits, the server will rebuild on the next request. All code is built using Deno on a separate build+proxy server. You can view the source here: https://github.com/maxmcd/vite-proxy
45## Architecture
67This project uses:
8- **Hono**: For API routes and server-side rendering
9- **Vite**: For frontend development and hot module replacement
10- **React**: For the UI components
1415The server is structured to:
161. Handle API routes with Hono
172. Proxy all other requests to the Vite development server
1819```ts
20// Create a main Hono app that will handle both API routes and proxy to Vite
21const mainApp = new Hono();
2223// Mount the Hono app from src/index.tsx to handle API routes
24mainApp.route("/api", app);
2526// For all other routes, use the Vite proxy
50When a request is received, the proxy downloads the entire project source (it can't be private) and builds it using Deno. Once the build is complete, all resulting files are cached and served quickly for future requests.
5152## API Routes
5354API routes are defined in `src/index.tsx` and are accessible under the `/api` path:
5556- `/api/clock` - Returns the current server time
57- `/api/hello` - Returns a hello message
5859## Client-Side
6061The client-side code uses Hono's client utilities to make API requests and React for rendering the UI.
HonoDenoVite2client.tsx4 matches
4import type { AppType } from ".";
56// Update the client to point to the API routes
7const client = hc<AppType>("/api");
89function App() {
13<h2>Example of useState()</h2>
14<Counter />
15<h2>Example of API fetch()</h2>
16<ClockButton />
17<h2>Example of another API endpoint</h2>
18<HelloButton />
19</>
HonoDenoVite2index.tsx3 matches
3const app = new Hono();
45// API routes
6app.get("/clock", (c) => {
7return c.json({
10});
1112// Add more API routes as needed
13app.get("/hello", (c) => {
14return c.json({
15message: "Hello from Hono API!",
16});
17});
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" },