15## Project Structure
1617- `/backend` - Hono API server with SQLite database
18- `/frontend` - HTML/JS frontend with Tailwind CSS
19- `/shared` - Shared types and utilities
numero-gamesREADME.md2 matches
9- Interactive practice with feedback
10- Mobile-friendly design with dark mode support
11- No external dependencies or API keys required
1213## How to Use
2223- Built as a single HTTP-triggered Val
24- Uses browser's built-in SpeechSynthesis API for text-to-speech
25- Styled with TailwindCSS
26- Includes dark mode support based on system preferences
reactHonoStarterREADME.md3 matches
39## Project Structure
4041- **Backend**: `/backend/index.ts` - Handles API requests and serves frontend assets
42- OpenAI integration for chat completions
43- API endpoints for authentication, chat, and user data
44- Supabase integration for database and authentication
4568- **Database**: Supabase
69- **Authentication**: Supabase Auth
70- **AI**: OpenAI API
71- **Styling**: Custom CSS with Tailwind utility classes
72
reactHonoStarterChatInterface.tsx6 matches
93
94try {
95// Send message to API
96const response = await fetch('/api/chat', {
97method: 'POST',
98headers: {
134
135// Save user message
136await fetch(`/api/conversations/${conversation.id}/messages`, {
137method: 'POST',
138headers: {
147
148// Save assistant message
149await fetch(`/api/conversations/${conversation.id}/messages`, {
150method: 'POST',
151headers: {
226const token = sessionData.access_token;
227
228await fetch(`/api/messages/${message.id}/favorite`, {
229method: 'PUT',
230headers: {
248
249if (!success) {
250// Fallback if Web Share API is not supported
251navigator.clipboard.writeText(message.content)
252.then(() => alert('Copied to clipboard!'))
reactHonoStarterSidebar.tsx1 match
38const token = sessionData.access_token;
39
40const response = await fetch('/api/conversations', {
41method: 'POST',
42headers: {
reactHonoStarterApp.tsx6 matches
31try {
32// Fetch agents
33const agentsResponse = await fetch('/api/agents');
34const agentsData = await agentsResponse.json();
35setAgents(agentsData.agents);
40
41// Fetch suggestions
42const suggestionsResponse = await fetch('/api/suggestions');
43const suggestionsData = await suggestionsResponse.json();
44setSuggestions(suggestionsData.suggestions);
45
46// Fetch categories
47const categoriesResponse = await fetch('/api/categories');
48const categoriesData = await categoriesResponse.json();
49setCategories(categoriesData.categories);
50
51// Fetch quick actions
52const quickActionsResponse = await fetch('/api/quick-actions');
53const quickActionsData = await quickActionsResponse.json();
54setQuickActions(quickActionsData.quickActions);
61const token = sessionData.access_token;
62
63const conversationsResponse = await fetch('/api/conversations', {
64headers: {
65'Authorization': `Bearer ${token}`
77
78// Fetch messages for the conversation
79const messagesResponse = await fetch(`/api/conversations/${latestConversation.id}/messages`, {
80headers: {
81'Authorization': `Bearer ${token}`
reactHonoStarterAuthContext.tsx6 matches
5253// Fetch user profile
54const response = await fetch('/api/profile', {
55headers: {
56'Authorization': `Bearer ${token}`
8283try {
84const response = await fetch('/api/auth/signin', {
85method: 'POST',
86headers: {
100101// Fetch user profile
102const profileResponse = await fetch('/api/profile', {
103headers: {
104'Authorization': `Bearer ${data.session.access_token}`
124125try {
126const response = await fetch('/api/auth/signup', {
127method: 'POST',
128headers: {
164165try {
166await fetch('/api/auth/signout', {
167method: 'POST'
168});
189const token = sessionData.access_token;
190191const response = await fetch('/api/settings', {
192method: 'PUT',
193headers: {
reactHonoStarterindex.ts28 matches
117app.get("/shared/**/*", c => serveFile(c.req.path, import.meta.url));
118119// API Routes
120121// Get AI agents
122app.get("/api/agents", async (c) => {
123try {
124// Try to get agents from database
138139// Get suggestion chips
140app.get("/api/suggestions", async (c) => {
141try {
142const category = c.req.query("category");
167168// Get categories
169app.get("/api/categories", async (c) => {
170try {
171// Try to get categories from database
185186// Get quick actions
187app.get("/api/quick-actions", async (c) => {
188try {
189// Try to get quick actions from database
202});
203204// Chat API endpoint - no auth required for demo
205app.post("/api/chat", async (c) => {
206try {
207const { message, agentId = "default", conversationId, messageHistory = [] } = await c.req.json();
281});
282} catch (error) {
283console.error("Error in chat API:", error);
284return c.json({ error: "Failed to process your request" }, 500);
285}
287288// Auth routes
289app.post("/api/auth/signup", async (c) => {
290try {
291const { email, password, username } = await c.req.json();
343});
344} catch (error) {
345console.error("Error in signup API:", error);
346return c.json({ error: "Failed to process your request" }, 500);
347}
348});
349350app.post("/api/auth/signin", async (c) => {
351try {
352const { email, password } = await c.req.json();
371});
372} catch (error) {
373console.error("Error in signin API:", error);
374return c.json({ error: "Failed to process your request" }, 500);
375}
376});
377378app.post("/api/auth/signout", async (c) => {
379try {
380const { error } = await supabase.auth.signOut();
386return c.json({ success: true });
387} catch (error) {
388console.error("Error in signout API:", error);
389return c.json({ error: "Failed to process your request" }, 500);
390}
393// Protected routes (require authentication)
394// Get user profile
395app.get("/api/profile", authMiddleware, async (c) => {
396try {
397const user = c.get("user");
428});
429} catch (error) {
430console.error("Error in profile API:", error);
431return c.json({ error: "Failed to process your request" }, 500);
432}
434435// Update user settings
436app.put("/api/settings", authMiddleware, async (c) => {
437try {
438const user = c.get("user");
454return c.json({ success: true });
455} catch (error) {
456console.error("Error in update settings API:", error);
457return c.json({ error: "Failed to process your request" }, 500);
458}
460461// Get user conversations
462app.get("/api/conversations", authMiddleware, async (c) => {
463try {
464const user = c.get("user");
477return c.json({ conversations: conversations || [] });
478} catch (error) {
479console.error("Error in conversations API:", error);
480return c.json({ error: "Failed to process your request" }, 500);
481}
483484// Create a new conversation
485app.post("/api/conversations", authMiddleware, async (c) => {
486try {
487const user = c.get("user");
507return c.json({ conversation: data[0] });
508} catch (error) {
509console.error("Error in create conversation API:", error);
510return c.json({ error: "Failed to process your request" }, 500);
511}
513514// Get messages for a conversation
515app.get("/api/conversations/:id/messages", authMiddleware, async (c) => {
516try {
517const user = c.get("user");
543return c.json({ messages: messages || [] });
544} catch (error) {
545console.error("Error in get messages API:", error);
546return c.json({ error: "Failed to process your request" }, 500);
547}
549550// Add a message to a conversation
551app.post("/api/conversations/:id/messages", authMiddleware, async (c) => {
552try {
553const user = c.get("user");
595return c.json({ message: data[0] });
596} catch (error) {
597console.error("Error in add message API:", error);
598return c.json({ error: "Failed to process your request" }, 500);
599}
601602// Toggle favorite status of a message
603app.put("/api/messages/:id/favorite", authMiddleware, async (c) => {
604try {
605const user = c.get("user");
637return c.json({ message: data[0] });
638} catch (error) {
639console.error("Error in favorite message API:", error);
640return c.json({ error: "Failed to process your request" }, 500);
641}
reactHonoStarterutils.ts1 match
82}
8384// Share text if Web Share API is supported
85export async function shareText(text: string, title: string = 'Shared from Pi'): Promise<boolean> {
86if (!navigator.share) return false;
RemovebackgroundREADME.md9 matches
1# Background Remover
23This Val Town project provides an API and web interface for removing backgrounds from images using the [Remove.bg](https://www.remove.bg/) API.
45## Features
9- Preview of original and processed images
10- Download option for processed images
11- API endpoint for programmatic use
1213## Setup
15To use this service, you need to:
16171. Create an account at [Remove.bg](https://www.remove.bg/) and get an API key
182. Add your API key as an environment variable in Val Town:
19- Variable name: `REMOVE_BG_API_KEY`
20- Value: Your Remove.bg API key
2122## Usage
30- Download the processed image with a transparent background
3132### API Usage
3334You can also use this as an API endpoint:
3536```javascript
37// Example: Using fetch to call the API
38async function removeBackground(imageFile) {
39const formData = new FormData();