MindfulMiles1-lunes.ts1 match
4const TEXT = "⏰ 8 часов работать";
56const url = `https://api.telegram.org/bot${TOKEN}/sendMessage`;
78fetch(url, {
reactHonoExampleREADME.md5 matches
8## Hono
910This app uses [Hono](https://hono.dev/) as the API framework. You can think of Hono as a replacement for [ExpressJS](https://expressjs.com/) that works in serverless environments like Val Town or Cloudflare Workers. If you come from Python or Ruby, Hono is also a lot like [Flask](https://github.com/pallets/flask) or [Sinatra](https://github.com/sinatra/sinatra), respectively.
1112## Serving assets to the frontend
20### `index.html`
2122The most complicated part of this backend API is serving index.html. In this app (like most apps) we serve it at the root, ie `GET /`.
2324We *bootstrap* `index.html` with some initial data from the server, so that it gets dynamically injected JSON data without having to make another round-trip request to the server to get that data on the frontend. This is a common pattern for client-side rendered apps.
2526## CRUD API Routes
2728This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
2930## Errors
3132Hono and other API frameworks have a habit of swallowing up Errors. We turn off this default behavior by re-throwing errors, because we think most of the time you'll want to see the full stack trace instead of merely "Internal Server Error". You can customize how you want errors to appear.
testefluxoapi.ts2 matches
1// --- api.ts ---
2// Funções de API para o backend do Val.town, chamadas pelo frontend.
34import { blob } from "https://esm.town/v/std/blob"; // Importa std/blob para persistência
testefluxomain.tsx17 matches
34// Importações para a lógica do Backend (executada no servidor Val.town)
5// Nota: Funções de utils, aiConverter e api são importadas diretamente aqui para o backend.
6import { convertToAI, deleteFlowchart, exportJSON, importJSON, loadFlowchart, saveFlowchart } from "./api.ts"; // Funções da API, incluindo deleteFlowchart
78// ==============================================================================
10// O código real está em utils.ts. Este arquivo main.tsx importa e usa.
11// ==============================================================================
12// Importado via 'api.ts' -> 'aiConverter.ts' -> 'utils.ts'
1314// ==============================================================================
16// O código real está em aiConverter.ts. Este arquivo main.tsx importa e usa.
17// ==============================================================================
18// Importado via 'api.ts'
1920// ==============================================================================
21// SEÇÃO 3: Funções de API (Backend)
22// O código real está em api.ts. Este arquivo main.tsx importa e usa.
23// ==============================================================================
24// (As funções saveFlowchart, convertToAI, etc. são usadas abaixo no roteamento)
432<button class="glass-button" data-node-type="input">📝 Entrada</button>
433<button class="glass-button" data-node-type="output">📤 Saída</button>
434<button class="glass-button" data-node-type="api">🌐 API</button>
435<button class="glass-button" data-node-type="end">⏹️ Fim</button>
436<button class="glass-button" id="saveFlowchart">💾 Salvar</button>
482<li>📝 <strong>Entrada:</strong> Coleta de dados ou informações.</li>
483<li>📤 <strong>Saída:</strong> Exibição ou entrega de resultados.</li>
484<li>🌐 <strong>API:</strong> Interação com serviços externos via API.</li>
485<li>⏹️ <strong>Fim:</strong> Ponto de saída do fluxograma.</li>
486</ul>
505// SEÇÃO 6: Ponto de Entrada do Val.town (Backend HTTP Handler)
506// Este é o principal handler HTTP para o Val.town.
507// Ele roteia as requisições para as funções de API ou serve o HTML.
508// ==============================================================================
509517const valName = "testefluxo"; // Nome do seu Val/Projeto
518519// Roteamento da API
520if (path === "/api/save-flowchart" && req.method === "POST") {
521return await saveFlowchart(req);
522}
523524if (path === "/api/convert-to-ai" && req.method === "POST") {
525return await convertToAI(req);
526}
527528if (path === "/api/load-flowchart" && req.method === "GET") {
529return await loadFlowchart(req);
530}
531532if (path === "/api/export-json" && req.method === "POST") {
533return await exportJSON(req);
534}
535536if (path === "/api/import-json" && req.method === "POST") {
537return await importJSON(req);
538}
539540if (path === "/api/delete-flowchart" && req.method === "DELETE") { // Nova rota para excluir
541return await deleteFlowchart(req);
542}
543544// Se não for uma rota de API, serve o HTML principal
545return new Response(getMainHTML(username, valName), {
546headers: {
testefluxoclient.ts6 matches
292newNode.subtype = "Texto";
293break;
294case "api":
295newNode.icon = "🌐";
296newNode.subtypes = ["GET", "POST", "PUT", "DELETE"];
477const flowchartName = prompt("Nome do fluxograma para salvar (ou deixe vazio para ID automático):");
478if (flowchartName !== null) { // Permite salvar com nome vazio (gera ID automático)
479const response = await fetch("/api/save-flowchart", {
480method: "POST",
481headers: { "Content-Type": "application/json" },
490const flowchartId = prompt("ID do fluxograma para carregar:");
491if (flowchartId) {
492const response = await fetch(`/api/load-flowchart?id=${flowchartId}`);
493const result = await response.json();
494if (result.success) {
504505document.getElementById("exportJson")?.addEventListener("click", async () => {
506const response = await fetch("/api/export-json", {
507method: "POST",
508headers: { "Content-Type": "application/json" },
535try {
536const jsonData = JSON.parse(event.target?.result as string);
537const response = await fetch("/api/import-json", {
538method: "POST",
539headers: { "Content-Type": "application/json" },
560561document.getElementById("convertToAI")?.addEventListener("click", async () => {
562const response = await fetch("/api/convert-to-ai", {
563method: "POST",
564headers: { "Content-Type": "application/json" },
testefluxoaiConverter.ts3 matches
1// --- aiConverter.ts ---
2// Lógica de conversão de fluxograma para instruções de IA, usada em api.ts.
34import {
87instructions.push({ type: "display_output", content: node.text, format: node.subtype });
88break;
89case "api":
90instructions.push({
91type: "make_api_call",
92endpoint: node.text,
93method: node.subtype,
testefluxoutils.ts3 matches
9export function calculateEstimatedDuration(steps: any[]): number {
10const baseDuration = steps.length * 2;
11const complexSteps = steps.filter(s => ["make_api_call", "database_operation"].includes(s.type)).length;
12return baseDuration + (complexSteps * 5);
13}
35steps.forEach(step => {
36switch (step.type) {
37case "make_api_call":
38permissions.add("network_access");
39break;
60const dependencies = new Set<string>();
61steps.forEach(step => {
62if (step.type === "make_api_call") {
63dependencies.add("http_client");
64}
ChatTESTING.md2 matches
253254```typescript
255// DOM APIs
256globalThis.localStorage = mockLocalStorage;
257globalThis.fetch = mockFetch;
258globalThis.crypto.randomUUID = mockUUID;
259260// Browser APIs
261navigator.clipboard = mockClipboard;
262globalThis.alert = mockAlert;
105- **Deno Standard Library**: For assertions
106- **Mock DOM**: Simulated browser environment
107- **Mock APIs**: localStorage, fetch, crypto.randomUUID
108- **Test Helpers**: Utilities for creating mock data
109