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";
8
9interface AppProps {
27 }
28
29 // Fetch todos from API
30 const fetchTodos = async () => {
31 if (!isAuthenticated) return;
33 setLoading(true);
34 try {
35 const response = await fetch('/api/todos');
36 const result: ApiResponse<Todo[]> = await response.json();
37
38 if (result.success && result.data) {
58 setLoading(true);
59 try {
60 const response = await fetch('/api/todos', {
61 method: 'POST',
62 headers: { 'Content-Type': 'application/json' },
64 });
65
66 const result: ApiResponse<Todo> = await response.json();
67
68 if (result.success && result.data) {
82 setLoading(true);
83 try {
84 const response = await fetch(`/api/todos/${id}`, {
85 method: 'PUT',
86 headers: { 'Content-Type': 'application/json' },
88 });
89
90 const result: ApiResponse<Todo> = await response.json();
91
92 if (result.success && result.data) {
108 setLoading(true);
109 try {
110 const response = await fetch(`/api/todos/${id}`, {
111 method: 'DELETE'
112 });
113
114 const result: ApiResponse = await response.json();
115
116 if (result.success) {
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 * {
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
3
4import { createClient } from "https://esm.sh/@supabase/supabase-js@2";
23}
24
25interface ApiResponse {
26 success: boolean;
27 data?: {
67 // Check authorization
68 const authHeader = req.headers.get("Authorization");
69 const apiKey = Deno.env.get("POSTS_API_KEY");
70
71 if (!apiKey || authHeader !== `Bearer ${apiKey}`) {
72 return new Response(
73 JSON.stringify({ success: false, error: "Unauthorized" }),
132
133 // Build response
134 const response: ApiResponse = {
135 success: true,
136 data: {
152 return new Response(JSON.stringify(response), { status: 200, headers });
153 } catch (error: any) {
154 console.error("API Error:", error);
155
156 const errorResponse: ApiResponse = {
157 success: false,
158 error: error.message || "Internal server error",
166}
167
168// API Documentation (for reference)
169/*
170# Posts API Documentation
171
172## Authentication
173All requests must include an Authorization header:
174Authorization: Bearer YOUR_API_KEY
175
176## Endpoints
12 },
13 {
14 "prompt": "weather dashboard for nyc using open-meteo API for NYC with icons",
15 "title": "Weather App",
16 "code":
8
91. Sign up for [Cerebras](https://cloud.cerebras.ai/)
102. Get a Cerebras API Key
113. Save it in your project env variable called `CEREBRAS_API_KEY`
211 } catch (error) {
212 Toastify({
213 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
214 position: "center",
215 duration: 3000,
5 <meta name="viewport" content="width=device-width, initial-scale=1.0">
6 <title>CerebrasCoder</title>
7 <link rel="preconnect" href="https://fonts.googleapis.com" />
8 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9 <link
10 href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
11 rel="stylesheet"
12 />
21 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
22 <meta property="og:type" content="website">
23 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
24
25
16 };
17 } else {
18 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
19 const completion = await client.chat.completions.create({
20 messages: [
281 }
282
283 // Optional: Add a small delay to be respectful to the API
284 if (fetchFullHistory) {
285 await new Promise(resolve => setTimeout(resolve, 100));