api_ianmenethil_comappConfig.ts7 matches
1// F:\zApps\valtown.servers\APIServer\src\core\app.config.ts
23import type { AppConfigShape, LogLevel } from "./appTypes.ts";
6export const APP_CONFIG: AppConfigShape = {
7server: {
8NAME: "Secure API Server",
9DESCRIPTION:
10"A secure, modular API server with OAuth, storage, and external service integration",
11VERSION: "2.0.0",
12BASE_URL: Deno.env.get("SERVER_BASE_URL") || "https://api.ianmenethil.com",
13ENVIRONMENT: Deno.env.get("DENO_ENV") || "development",
14PORT: parseInt(Deno.env.get("PORT") || "8000"),
15HOST: Deno.env.get("HOST") || "0.0.0.0",
16},
17api: {
18PUBLIC_API_PREFIX: "/v1",
19INTERNAL_API_PREFIX: "/",
20WEBHOOK_PREFIX: "/webhooks",
21CALLBACK_PREFIX: "/callbacks",
api_ianmenethil_comindex.ts1 match
1// F:\zApps\valtown.servers\APIServer\src\config\index.ts
2export { APP_CONFIG, getConfig } from "../core/appConfig.ts";
3export * from "../core/appTypes.ts";
hm-invoicesv1types.ts2 matches
49}
5051// API response interfaces
52export interface ApiResponse<T> {
53success: boolean;
54data?: T;
hm-invoicesv1val-town.mdc10 matches
18- Generate code in TypeScript or TSX
19- Add appropriate TypeScript types and interfaces for all data structures
20- Prefer official SDKs or libraries than writing API calls directly
21- Ask the user to supply API or library documentation if you are at all unsure about it
22- **Never bake in secrets into the code** - always use environment variables
23- Include comments explaining complex logic (avoid commenting obvious operations)
28### 1. HTTP Trigger
2930- Create web APIs and endpoints
31- Handle HTTP requests and responses
32- Example structure:
138However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
139If you need access to this data on the client, run it in the server and pass it to the client by splicing it into the HTML page
140or by making an API request for it.
141142## Val Town Platform Specifics
146- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
147- **Storage:** DO NOT use the Deno KV module for storage
148- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
149- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
150- **View Source:** Add a view source link by importing & using `import.meta.url.replace("ems.sh", "val.town)"` (or passing this data to the client) and include `target="_top"` attribute
151- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
152- **Error Handling:** Only use try...catch when there's a clear local resolution; Avoid catches that merely log or return 500s. Let errors bubble up with full context
153- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
154- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
155- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
376### Backend (Hono) Best Practices
377378- Hono is the recommended API framework
379- Main entry point should be `main.tsx`
380- **Database Setup:** Use the admin utilities to handle table creation and seeding. Backend should focus on CRUD operations only
402});
403```
404- Create RESTful API routes for CRUD operations
405- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
406```ts
442- For files in the project, use `readFile` helpers
4434445. **API Design:**
445- `fetch` handler is the entry point for HTTP vals
446- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
68---
6970## Phase 2: Core Backend API
71**Goal**: Build RESTful API endpoints for invoice management
7273### Tasks:
741. **Main API Setup**
75- Create `main.tsx` with Hono app configuration
76- Set up error handling and static file serving
77- Configure CORS if needed
78792. **Invoice API Endpoints**
80- `GET /api/invoices` - List all invoices with filtering
81- `POST /api/invoices` - Create new invoice
82- `PUT /api/invoices/:id` - Update invoice (mainly status changes)
83- `DELETE /api/invoices/:id` - Delete invoice
84- `GET /api/invoices/stats` - Dashboard statistics
85863. **Vendor API Endpoints**
87- `GET /api/vendors` - List all vendors
88- `PUT /api/vendors/:id` - Update vendor name
8990### Deliverables:
91- Complete REST API for invoice management
92- API endpoints tested via admin tools or direct calls
93- Proper error handling and validation
94182183## Technical Stack
184- **Backend**: Hono.js for API routes
185- **Database**: SQLite with Val Town's sqlite service
186- **Frontend**: React 18.2.0 with TypeScript
2072081. **Phase 1: Foundation & Database Setup** - Get the core database structure and admin tools working
2092. **Phase 2: Core Backend API** - Build the REST API endpoints for managing invoices and vendors
2103. **Phase 3: Frontend Foundation** - Create the basic React UI with invoice display and forms
2114. **Phase 4: Enhanced UI & Interactions** - Add advanced features like dashboard, filtering, and bulk operations
223- Uses Val Town best practices with proper project structure
224- SQLite database with proper schema and constraints
225- Hono.js backend with RESTful API design
226- React frontend with TailwindCSS for styling
227- Admin utilities for easy database management and seeding
238- add a checkbox that the llm can mark off after completeing a phase.
239- no need for code to "Update vendor name" i will do that manually in admin code
240- no need to " - `DELETE /api/invoices/:id` - Delete invoice" , i'll do that using SQL commands , so add to plan to create a section in "db-tools.tsx" with some SQL commands that i can easily copy to run and a link to the database explorer "https://arfan25-admin-sqliteexplorerapp.val.run/"
241242---
261## Phase Completion Checklist
262- [ ] Phase 1: Foundation & Database Setup
263- [ ] Phase 2: Core Backend API
264- [ ] Phase 3: Frontend Foundation
265- [ ] Phase 4: Enhanced UI & Interactions
284285```markdown
2862. **Invoice API Endpoints**
287- `GET /api/invoices` - List all invoices with filtering
288- `POST /api/invoices` - Create new invoice
289- `PUT /api/invoices/:id` - Update invoice (mainly status changes)
290- `DELETE /api/invoices/:id` - Delete invoice
291- `GET /api/invoices/stats` - Dashboard statistics
2922933. **Vendor API Endpoints**
294- `GET /api/vendors` - List all vendors
295- `PUT /api/vendors/:id` - Update vendor name
296297->
2982992. **Invoice API Endpoints**
300- `GET /api/invoices` - List all invoices with filtering
301- `POST /api/invoices` - Create new invoice
302- `PUT /api/invoices/:id` - Update invoice (mainly status changes)
303- `GET /api/invoices/stats` - Dashboard statistics
3043053. **Vendor API Endpoints**
306- `GET /api/vendors` - List all vendors
307```
308353```markdown
354## Technical Stack
355- **Backend**: Hono.js for API routes
356- **Database**: SQLite with Val Town's sqlite service
357- **Frontend**: React 18.2.0 with TypeScript
362363## Technical Stack
364- **Backend**: Hono.js for API routes
365- **Database**: SQLite with Val Town's sqlite service
366- **Frontend**: React 18.2.0 with TypeScript
406- Updated technical stack to mention DaisyUI, nord theme, and Iconify v3
407408✅ **Removed vendor name update API** - No longer planning to build `PUT /api/vendors/:id` endpoint since you'll handle this manually in admin tools
409410✅ **Removed delete invoice API** - No longer planning `DELETE /api/invoices/:id` endpoint since you'll use SQL commands directly
411412✅ **Enhanced admin tools** - Added to Phase 1:
api_ianmenethil_compackage.json2 matches
1{
2"name": "modular-api-server",
3"version": "1.0.0",
4"description": "A modular API server with OpenAPI-driven routing",
5"main": "main.tsx",
6"type": "module",
api_ianmenethil_commain.tsx9 matches
1// F:\zApps\valtown.servers\APIServer\main.tsx
2import { Hono } from "hono";
3import type { HonoVariables } from "@/core/requestTypes.ts";
4import { APP_CONFIG } from "@/config/index.ts";
5import { generateRoutesFromOpenAPI } from "./src/openapi/routeGenerator.ts";
67const app = new Hono<{ Variables: HonoVariables }>();
18initializationPromise = (async () => {
19try {
20const specPath = "./src/openapi/spec";
21const result = await generateRoutesFromOpenAPI(app, specPath);
22const routes = result.routes;
23console.log(`✅ Initialized ${routes.length} routes from OpenAPI spec`);
24routesInitialized = true;
25return true;
26} catch (error) {
27console.error("❌ Failed to initialize routes from OpenAPI:", error);
28app.all("*", (c) => {
29return c.json(
32error: {
33code: "SERVICE_UNAVAILABLE",
34message: "API routes not available - OpenAPI initialization failed",
35details: error instanceof Error ? error.message : "Unknown error",
36},
82console.log(`📚 Swagger --> ${APP_CONFIG.server.BASE_URL}/docs`);
83console.log(`🔗 Redocly --> ${APP_CONFIG.server.BASE_URL}/redoc`);
84console.log(`🌐 OpenAPI Spec --> ${APP_CONFIG.server.BASE_URL}/openapi.json`);
85console.log(`🌐 OpenAPI Spec --> ${APP_CONFIG.server.BASE_URL}/openapi.yaml`);
86await initializeRoutes();
87Deno.serve(
api_ianmenethil_comdeno.json2 matches
29"@/config/": "./src/config/",
30"@/core/": "./src/core/",
31"@/external-apis/": "./src/external-apis/",
32"@/gateway/": "./src/gateway/",
33"@/handlers/": "./src/handlers/",
34"@/h/oauth/": "./src/handlers/oauth/",
35"@/middleware/": "./src/middleware/",
36"@/openapi/": "./src/openapi/",
37"@/routes/": "./src/routes/",
38"@/services/": "./src/services/",
invest-trackermacro_news_daily.tsx3 matches
1// macro_news_daily.tsx — twice/day @ 04 & 16 UTC
2import { blob } from "https://esm.town/v/std/blob";
3const KEY = Deno.env.get("NEWSAPI");
45export default async function run() {
6const q = encodeURIComponent(`Fed OR CPI OR inflation OR ECB OR RBA`);
7const url = `https://newsapi.org/v2/everything?` +
8`q=${q}&language=en&sortBy=publishedAt&pageSize=10&apiKey=${KEY}`;
910const arts = (await fetch(url).then(r=>r.json())).articles ?? [];
92<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Honeydew</title>
93<style>
94@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600&family=Inter:wght@400&display=swap');
95@keyframes spin{to{transform:rotate(360deg)}}
96@keyframes slide-in-bounce {
474<script>
475(function() {
476const API_URL = '${sourceUrl}';
477const STORE_KEYS = { projects: 'honeydew_projects_v1', tasks: 'honeydew_tasks_v1', theme: 'honeydew_theme_v1' };
478let projects = [], tasks = [], activeView = 'today', conversationHistory = [];
679680try {
681const res = await fetch(\`\${API_URL}?action=chat\`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ messages: conversationHistory.slice(0, -1), tasks, projects }) });
682const data = await res.json();
683if (!res.ok || data.error) throw new Error(data.error || 'Server error');
783toggleLoading(btn, true);
784try {
785const res = await fetch(\`\${API_URL}?action=synthesizeProject\`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ goal }) });
786const data = await res.json();
787if (!res.ok || data.error) throw new Error(data.error || "Server error");
801toggleLoading(btn, true);
802try {
803const res = await fetch(\`\${API_URL}?action=dailyRebalance\`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ tasks: todayTasks }) });
804const data = await res.json();
805if (!res.ok || data.error) throw new Error(data.error || "Server error");
1031}
1032} catch (error) {
1033console.error("AI API Error:", error);
1034return new Response(
1035JSON.stringify({ error: error.message || "An unknown error occurred with the AI service." }),