12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
1314// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
1617// Unwrap and rethrow Hono errors as the original error
36}
3738export interface ApiResponse<T = any> {
39success: boolean;
40data?: T;
todo-appTodoList.tsx1 match
179<span className="text-sm text-gray-500">{getCategoryLabel(todo.category)}</span>
180<span className="text-sm">{getPriorityIcon(todo.priority)}</span>
181<span className="text-xs text-gray-500 capitalize">{todo.priority === 'high' ? 'Alta' : todo.priority === 'medium' ? 'Média' : 'Baixa'} prioridade</span>
182{isOverdue(todo.dueDate) && !todo.completed && (
183<span className="text-xs bg-red-100 text-red-700 px-2 py-1 rounded-full">
19```
20├── backend/
21│ ├── index.ts # Servidor Hono com API REST
22│ └── README.md
23├── frontend/
36```
3738## 🚀 API Endpoints
3940- `GET /` - Página inicial (landing page ou app)
41- `GET /api/todos` - Buscar tarefas do usuário
42- `POST /api/todos` - Criar nova tarefa
43- `PUT /api/todos/:id` - Atualizar tarefa
44- `DELETE /api/todos/:id` - Excluir tarefa
4546## 🔧 Tecnologias
3import { blob } from "https://esm.town/v/std/blob";
4import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
5import type { Todo, User, CreateTodoRequest, UpdateTodoRequest, ApiResponse } from "../shared/types.ts";
67const app = new Hono();
69});
7071// API Routes
7273// Get todos for authenticated user
74app.get("/api/todos", async (c) => {
75const email = c.req.header("X-LastLogin-Email");
76
77if (!email) {
78return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
79}
8081try {
82const userData = await getUserData(email);
83return c.json<ApiResponse<Todo[]>>({ success: true, data: userData.todos });
84} catch (error) {
85return c.json<ApiResponse>({ success: false, error: "Failed to fetch todos" }, 500);
86}
87});
8889// Create new todo
90app.post("/api/todos", async (c) => {
91const email = c.req.header("X-LastLogin-Email");
92
93if (!email) {
94return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
95}
96114await saveUserData(userData);
115116return c.json<ApiResponse<Todo>>({ success: true, data: newTodo });
117} catch (error) {
118return c.json<ApiResponse>({ success: false, error: "Failed to create todo" }, 500);
119}
120});
121122// Update todo
123app.put("/api/todos/:id", async (c) => {
124const email = c.req.header("X-LastLogin-Email");
125const todoId = c.req.param("id");
126
127if (!email) {
128return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
129}
130135const todoIndex = userData.todos.findIndex(todo => todo.id === todoId);
136if (todoIndex === -1) {
137return c.json<ApiResponse>({ success: false, error: "Todo not found" }, 404);
138}
139148await saveUserData(userData);
149150return c.json<ApiResponse<Todo>>({ success: true, data: updatedTodo });
151} catch (error) {
152return c.json<ApiResponse>({ success: false, error: "Failed to update todo" }, 500);
153}
154});
155156// Delete todo
157app.delete("/api/todos/:id", async (c) => {
158const email = c.req.header("X-LastLogin-Email");
159const todoId = c.req.param("id");
160
161if (!email) {
162return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
163}
164168const todoIndex = userData.todos.findIndex(todo => todo.id === todoId);
169if (todoIndex === -1) {
170return c.json<ApiResponse>({ success: false, error: "Todo not found" }, 404);
171}
172174await saveUserData(userData);
175176return c.json<ApiResponse>({ success: true });
177} catch (error) {
178return c.json<ApiResponse>({ success: false, error: "Failed to delete todo" }, 500);
179}
180});
todo-appindex.html1 match
7<script src="https://cdn.twind.style" crossorigin></script>
8<script src="https://esm.town/v/std/catch"></script>
9<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
10<style>
11* {
5import TodoForm from "./TodoForm.tsx";
6import LandingPage from "./LandingPage.tsx";
7import type { Todo, User, ApiResponse } from "../../shared/types.ts";
89interface AppProps {
27}
2829// Fetch todos from API
30const fetchTodos = async () => {
31if (!isAuthenticated) return;
33setLoading(true);
34try {
35const response = await fetch('/api/todos');
36const result: ApiResponse<Todo[]> = await response.json();
37
38if (result.success && result.data) {
58setLoading(true);
59try {
60const response = await fetch('/api/todos', {
61method: 'POST',
62headers: { 'Content-Type': 'application/json' },
64});
65
66const result: ApiResponse<Todo> = await response.json();
67
68if (result.success && result.data) {
82setLoading(true);
83try {
84const response = await fetch(`/api/todos/${id}`, {
85method: 'PUT',
86headers: { 'Content-Type': 'application/json' },
88});
89
90const result: ApiResponse<Todo> = await response.json();
91
92if (result.success && result.data) {
108setLoading(true);
109try {
110const response = await fetch(`/api/todos/${id}`, {
111method: 'DELETE'
112});
113
114const result: ApiResponse = await response.json();
115
116if (result.success) {
dashboard-propsv1main.tsx1 match
5<meta name="viewport" content="width=device-width, initial-scale=1.0">
6<title>CICERO Dashboard - Professional Landing Pages</title>
7<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;500;900&display=swap" rel="stylesheet">
8<style>
9* {
fetch-socialsendpoint.tsx10 matches
1// Val.town HTTP endpoint to serve archived posts with pagination and filtering
2// This will be accessible at: https://USERNAME-posts-api.web.val.run
34import { createClient } from "https://esm.sh/@supabase/supabase-js@2";
23}
2425interface ApiResponse {
26success: boolean;
27data?: {
67// Check authorization
68const authHeader = req.headers.get("Authorization");
69const apiKey = Deno.env.get("POSTS_API_KEY");
7071if (!apiKey || authHeader !== `Bearer ${apiKey}`) {
72return new Response(
73JSON.stringify({ success: false, error: "Unauthorized" }),
132133// Build response
134const response: ApiResponse = {
135success: true,
136data: {
152return new Response(JSON.stringify(response), { status: 200, headers });
153} catch (error: any) {
154console.error("API Error:", error);
155156const errorResponse: ApiResponse = {
157success: false,
158error: error.message || "Internal server error",
166}
167168// API Documentation (for reference)
169/*
170# Posts API Documentation
171172## Authentication
173All requests must include an Authorization header:
174Authorization: Bearer YOUR_API_KEY
175176## Endpoints
12},
13{
14"prompt": "weather dashboard for nyc using open-meteo API for NYC with icons",
15"title": "Weather App",
16"code":