43You'll need to set up some environment variables to make it run.
44
45- `ANTHROPIC_API_KEY` for LLM calls
46- You'll need to follow [these instructions](https://docs.val.town/integrations/telegram/) to make a telegram bot, and set `TELEGRAM_TOKEN`. You'll also need to get a `TELEGRAM_CHAT_ID` in order to have the bot remember chat contents.
47- For the Google Calendar integration you'll need `GOOGLE_CALENDAR_ACCOUNT_ID` and `GOOGLE_CALENDAR_CALENDAR_ID`. See [these instuctions](https://www.val.town/v/stevekrouse/pipedream) for details.
108
109export default async function server(request: Request): Promise<Response> {
110 const apiKey = Deno.env.get('READWISE_API_KEY');
111
112 if (request.url.includes('/books')) {
113 try {
114 const booksResponse = await fetch('https://readwise.io/api/v2/books/?category=books', {
115 headers: {
116 'Authorization': `Token ${apiKey}`,
117 'Content-Type': 'application/json'
118 }
139
140 try {
141 const highlightsResponse = await fetch(`https://readwise.io/api/v2/highlights/?book_id=${bookId}`, {
142 headers: {
143 'Authorization': `Token ${apiKey}`,
144 'Content-Type': 'application/json'
145 }
3
4const openai = new OpenAI();
5const KEY = "productSummaryApi";
6const TABLE_NAME = `${KEY}_summaries_v4`;
7
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error
9
10/**
11 * API for generating SVG logos with one or two lines of text
12 * GET Parameters:
13 * - topWord: Top text or single line text (required)
20 * - singleLine: "true" for single line mode, any other value for two-line mode
21 */
22export default async function api(request: Request): Promise<Response> {
23 // Extract URL parameters
24 const url = new URL(request.url);
2import React from "https://esm.sh/react@18.2.0";
3
4// Common logo generation logic to share between web UI and API
5
6// Fixed corner radius from OpenMoji design (15px)
1# Two-Line Logo Generator API
2
3This API allows you to generate SVG logos with one or two lines of text, similar to the interactive logo generator. The API returns either the SVG content directly or as a data URL.
4
5## API Endpoint
6
7```
25## Available Fonts
26
27The API supports the following font options:
28- Arial
29- Helvetica
93- Font sizes are automatically calculated based on text length
94- The corner radius is fixed at 15px (same as the OpenMoji design)
95- The API uses CORS headers to allow cross-origin requests
96
5export const uploadSvgToHost = async (svgString, title = "Logo") => {
6 try {
7 // Use the same API endpoint as the OpenMoji generator
8 const apiUrl = "https://svgur.com/i.json";
9
10 // Create a form data object to match the API requirements
11 const formData = new FormData();
12 formData.append('source', svgString);
13 formData.append('title', title);
14
15 // Make the API request
16 const response = await fetch(apiUrl, {
17 method: 'POST',
18 body: formData,
20
21 if (!response.ok) {
22 throw new Error(`API responded with status: ${response.status}`);
23 }
24
35 };
36 } else {
37 throw new Error('API response missing expected data');
38 }
39
41 console.error("Error uploading SVG:", error);
42
43 // Fallback to data URL if API fails
44 try {
45 const svgBase64 = btoa(unescape(encodeURIComponent(svgString)));
55 return {
56 success: false,
57 error: `API Error: ${error.message}. Fallback also failed: ${fallbackError.message}`
58 };
59 }
8app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
9
10// app.get("/api/get/:key", async c => c.json(await db.get(c.req.param("key"))));
11// app.get("/api/set/:key/:value", async c => c.json(await db.set(c.req.param("key"), c.req.param("value"))));
12
13app.get("/api/data", c => c.json({ hello: "world" }));
14
15app.get("/", async c => serveFile("/frontend/index.html", import.meta.url));