49 this.isLoading = true;
50 try {
51 const response = await fetch('/api/jobs');
52 const result = await response.json();
53
69
70 try {
71 const response = await fetch('/api/chat');
72 const result = await response.json();
73
101
102 try {
103 const response = await fetch('/api/chat', {
104 method: 'POST',
105 headers: {
151 if (this.editingJob) {
152 // Update existing job
153 response = await fetch(`/api/jobs/${this.editingJob.id}`, {
154 method: 'PUT',
155 headers: {
160 } else {
161 // Create new job
162 response = await fetch('/api/jobs', {
163 method: 'POST',
164 headers: {
190
191 try {
192 const response = await fetch(`/api/jobs/${jobId}`, {
193 method: 'DELETE'
194 });
13## Project Structure
14
15- `/backend` - Server-side code using Hono for API endpoints and SQLite for data storage
16- `/frontend` - Client-side code using React and TailwindCSS
17- `/shared` - Shared types and utilities used by both frontend and backend
23## Technologies Used
24
25- Hono (Backend API framework)
26- SQLite (Database)
27- React (Frontend UI)
17├── backend/
18│ ├── database/ # SQLite database setup and queries
19│ ├── routes/ # API endpoints
20│ └── index.ts # Main entry point
21├── frontend/
13## Project Structure
14
15- `/backend` - Server-side code for handling authentication and API requests
16- `/frontend` - Client-side code including HTML, React components, and styles
17- `/shared` - Shared types and utilities used by both frontend and backend
21- TypeScript
22- React
23- AT Protocol (@atproto/api)
24- Tailwind CSS (via Twind)
25- Hono (for backend API)
26- Val Town blob storage (for session management)
27
1# Backend API
2
3This directory contains the server-side code for the Bluesky Likes Search application.
4
5## API Endpoints
6
7### POST /api/login
8Authenticates a user with Bluesky using their credentials and creates a session.
9
26```
27
28### POST /api/likes
29Fetches a user's likes, with optional search filtering.
30
48```
49
50### POST /api/logout
51Logs out a user by invalidating their session.
52
104
105 try {
106 const response = await fetch("/api/login", {
107 method: "POST",
108 headers: {
145
146 try {
147 const response = await fetch("/api/likes", {
148 method: "POST",
149 headers: {
184 if (sessionToken) {
185 try {
186 // Call logout API to clear session on server
187 await fetch("/api/logout", {
188 method: "POST",
189 headers: {
28});
29
30// API Routes
31const api = new Hono();
32
33// Get all tasks
34api.get("/tasks", async c => {
35 const tasks = await getAllTasks();
36 return c.json(tasks);
38
39// Create a new task
40api.post("/tasks", async c => {
41 const { description } = await c.req.json();
42
50
51// Update task status
52api.put("/tasks/:id", async c => {
53 const id = parseInt(c.req.param("id"));
54 const { completed } = await c.req.json();
68
69// Delete a task
70api.delete("/tasks/:id", async c => {
71 const id = parseInt(c.req.param("id"));
72
84});
85
86// Mount API routes
87app.route("/api", api);
88
89// This is the entry point for HTTP vals
77 const emptyState = document.getElementById('empty-state');
78
79 // API endpoints
80 const API_URL = '/api/tasks';
81
82 // Load tasks on page load
91
92 try {
93 const response = await fetch(API_URL, {
94 method: 'POST',
95 headers: {
116 async function fetchTasks() {
117 try {
118 const response = await fetch(API_URL);
119
120 if (!response.ok) {
176 async function toggleTaskStatus(taskId, completed) {
177 try {
178 const response = await fetch(`${API_URL}/${taskId}`, {
179 method: 'PUT',
180 headers: {
213
214 try {
215 const response = await fetch(`${API_URL}/${taskId}`, {
216 method: 'DELETE'
217 });
1# AI Agent with Memory
2
3This is an AI agent that can save information to its memory and retrieve it when answering questions. The agent uses SQLite for persistent storage and OpenAI's API for generating responses.
4
5## Features
36- **Backend**: TypeScript with Deno runtime
37- **Database**: SQLite for persistent storage
38- **AI**: OpenAI API for generating responses
39- **Frontend**: HTML, JavaScript, and Twind (Tailwind CSS in JS)
40
1import { Hono } from "https://esm.sh/hono@3.12.6";
2import { cors } from "https://esm.sh/hono@3.12.6/cors";
3import { BskyAgent } from "https://esm.sh/@atproto/api@0.7.3";
4import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
5import { parseProject } from "https://esm.town/v/std/utils@85-main/index.ts";
43}
44
45// API endpoint for Bluesky login
46app.post("/api/login", async c => {
47 try {
48 const { identifier, password } = await c.req.json();
83});
84
85// API endpoint to fetch user likes
86app.post("/api/likes", async c => {
87 try {
88 const { sessionToken, cursor, limit = 50, searchQuery = "" } = await c.req.json();
148
149// Logout endpoint to clear session
150app.post("/api/logout", async c => {
151 try {
152 const { sessionToken } = await c.req.json();