62};
63
64export function App() {
65 const [memories, setMemories] = useState<Memory[]>([]);
66 const [loading, setLoading] = useState(true);
139 const data = await response.json();
140
141 // Change the sorting function to show memories in chronological order
142 const sortedMemories = [...data].sort((a, b) => {
143 const dateA = a.createdDate || 0;
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(
6
7// Initialize database tables
8export async function initDatabase() {
9 try {
10 await sqlite.execute(`
28
29// Create a new prompt request
30export async function createPromptRequest(request: PromptRequest): Promise<number> {
31 const { email, existingPrompt, expectedOutcome, issueDescription } = request;
32
54
55// Get all prompt requests
56export async function getAllPromptRequests(): Promise<PromptRequest[]> {
57 try {
58 const result = await sqlite.execute(`SELECT * FROM ${PROMPTS_TABLE} ORDER BY created_at DESC`);
66
67// Get a single prompt request by ID
68export async function getPromptRequestById(id: number): Promise<PromptRequest | null> {
69 try {
70 const result = await sqlite.execute(
85
86// Update a prompt request with the fixed prompt
87export async function updatePromptRequest(id: number, updatedPrompt: string): Promise<boolean> {
88 try {
89 await sqlite.execute(
101}
102
103// Helper function to map a database row to a PromptRequest object
104function mapRowToPromptRequest(row: any[], columns: string[]): PromptRequest {
105 const result: Record<string, any> = {};
106
6//const tableName = "memories_demo";
7
8export async function getAllMemories(): Promise<Memory[]> {
9 const result = await sqlite.execute(
10 `SELECT id, date, text, createdBy, createdDate, tags FROM ${tableName}
23}
24
25export async function createMemory(
26 memory: Omit<Memory, "id">
27): Promise<Memory> {
51}
52
53export async function updateMemory(
54 id: string,
55 memory: Partial<Omit<Memory, "id">>
70}
71
72export async function deleteMemory(id: string): Promise<void> {
73 await sqlite.execute(`DELETE FROM ${tableName} WHERE id = ?`, [id]);
74}
72### Code Blocks
73```javascript
74function hello() {
75 console.log("Hello, world!");
76}
2const path = require('node:path');
3
4function getTitleFromMarkdown(filePath) {
5 try {
6 const content = fs.readFileSync(filePath, 'utf8');
26}
27
28function generateDocsConfig() {
29 const docsDir = path.join(__dirname, '../docs');
30 const configPath = path.join(__dirname, '../src/components/config.ts');
31 const docs = [];
32
33 function scanDirectory(dir) {
34 const files = fs.readdirSync(dir);
35
1import { blob } from "https://esm.town/v/std/blob?v=12";
2
3export default async function(interval: Interval) {
4 // get the "filename"
5 // this is the string at the beginning of each blob key... (cont'd)
9const thisURL = parseProject(import.meta.url).links.self.project;
10
11function StatusRow({ rows }) {
12 return (
13 <div className="w-full flex flex-col space-y-2">
31}
32
33function StatusSection({ url, rows }) {
34 const sectionRows = rows.filter(row => row[0] === url);
35 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
47}
48
49export default async function(req: Request): Promise<Response> {
50 const { rows } = await sqlite.execute(
51 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2export function SparklineSVG({ strokeWidth = 2, data = [], fill = "none", stroke = "black" }) {
3 const padding = 2;
4 const xMargin = 25;
4const thisURL = parseProject(import.meta.url).links.self.latest;
5
6export async function notify(message: string) {
7 await email({ subject: message, text: `Email sent from ${thisURL}` });
8}