2import { cors } from "https://esm.sh/hono@3.12.6/cors";
3import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
4import { initDatabase } from "./database/migrations.ts";
5import {
6getAllJobs,
8getRecentMessages,
9createMessage
10} from "./database/queries.ts";
1112// Initialize the app
21app.use("*", cors());
2223// Initialize database on startup
24await initDatabase();
2526// API Routes
zaymigrations.ts2 matches
67/**
8* Initialize database tables
9*/
10export async function initDatabase() {
11// Create jobs table
12await sqlite.execute(`
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
Micro-service-1README.md1 match
1718- Frontend: HTML, CSS, JavaScript
19- Backend/Database: Supabase (PostgreSQL)
20- Deployment: Vercel
21- Version Control: Git
reactHonoStarterREADME.md3 matches
29- **Theme Options**: Light, dark, and system theme support
3031### Database Structure
3233- **Conversations**: Store chat history
42- OpenAI integration for chat completions
43- API endpoints for authentication, chat, and user data
44- Supabase integration for database and authentication
4546- **Frontend**:
66- **Frontend**: React with TypeScript
67- **Backend**: Hono on Deno
68- **Database**: Supabase
69- **Authentication**: Supabase Auth
70- **AI**: OpenAI API
218setMessages(updatedMessages);
219
220// If user is logged in, update in database
221if (user && conversation) {
222try {
reactHonoStarterindex.ts13 matches
9const openai = new OpenAI();
1011// Default AI agents if database is not set up
12const DEFAULT_AGENTS: AIAgent[] = [
13{
122app.get("/api/agents", async (c) => {
123try {
124// Try to get agents from database
125const { data: agents, error } = await supabase.from("ai_agents").select("*");
126
127if (error || !agents || agents.length === 0) {
128// Return default agents if database is not set up
129return c.json({ agents: DEFAULT_AGENTS });
130}
142const category = c.req.query("category");
143
144// Try to get suggestions from database
145let query = supabase.from("suggestion_chips").select("*");
146if (category) {
151
152if (error || !suggestions || suggestions.length === 0) {
153// Return default suggestions if database is not set up
154return c.json({
155suggestions: category
169app.get("/api/categories", async (c) => {
170try {
171// Try to get categories from database
172const { data: categories, error } = await supabase.from("categories").select("*");
173
174if (error || !categories || categories.length === 0) {
175// Return default categories if database is not set up
176return c.json({ categories: DEFAULT_CATEGORIES });
177}
187app.get("/api/quick-actions", async (c) => {
188try {
189// Try to get quick actions from database
190const { data: quickActions, error } = await supabase.from("quick_actions").select("*");
191
192if (error || !quickActions || quickActions.length === 0) {
193// Return default quick actions if database is not set up
194return c.json({ quickActions: DEFAULT_QUICK_ACTIONS });
195}
216
217if (!agents || agents.length === 0) {
218// Use default agent if not found in database
219agent = DEFAULT_AGENTS.find(a => a.id === agentId) || DEFAULT_AGENTS[0];
220} else {
310}
311
312// Create user profile in database
313if (data.user) {
314const { error: profileError } = await supabase.from("users").insert({
397const user = c.get("user");
398
399// Get user profile from database
400const { data: profile, error } = await supabase
401.from("users")
464const user = c.get("user");
465
466// Get user conversations from database
467const { data: conversations, error } = await supabase
468.from("conversations")
reactHonoStartersupabase.ts1 match
36}
3738// Database helper functions
39export async function getUser(userId: string) {
40const { data, error } = await supabase
9- [ ] make it one click to branch off like old jp townie demos
10- [ ] opentownie as a pr bot
11- [ ] give it the ability to see its own client-side and server-side logs by building a middleware that shoves them into a SQL light database date and then give it a tool to access them
12- [ ] do a browser use or screenshot thing to give it access to its own visual output
13- [ ] Have it default to creating a new branch off main
7export const thinkTool = tool({
8description:
9"Use the tool to think about something. It will not obtain new information or change the database, but just append the thought to the log. Use it when complex reasoning or some cache memory is needed.",
10parameters: z.object({
11thought: z.string().describe("A thought to think about."),