16};
17} else {
18const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
19const completion = await client.chat.completions.create({
20messages: [
my-first-valDashboard.tsx1 match
167<div className="flex justify-between">
168<span className="text-gray-600">Current Tab</span>
169<span className="font-medium capitalize">{activeTab}</span>
170</div>
171</div>
my-first-valindex.ts4 matches
27});
2829// API routes
30app.route('/api/auth', authRoutes);
31app.route('/api/media', mediaRoutes);
3233// Serve static files
42// Inject initial configuration
43const config = {
44apiUrl: '/api',
45maxFileSize: 50 * 1024 * 1024, // 50MB
46supportedFormats: {
my-first-valai-analysis.ts3 matches
78try {
79// For audio analysis, we'll use Whisper for transcription and then analyze the text
80// Note: This is a simplified approach. In production, you might want to use specialized audio analysis APIs
81
82// Convert base64 to blob for Whisper API
83const base64Data = audioData.replace(/^data:audio\/[^;]+;base64,/, '');
84const audioBuffer = Uint8Array.from(atob(base64Data), c => c.charCodeAt(0));
85const audioBlob = new Blob([audioBuffer], { type: 'audio/wav' });
86
87// Create a File object for the API
88const audioFile = new File([audioBlob], fileName, { type: 'audio/wav' });
89
my-first-valtypes.ts1 match
58}
5960export interface ApiResponse<T = any> {
61success: boolean;
62data?: T;
my-first-valREADME.md12 matches
1516### Backend (`/backend/`)
17- **index.ts**: Main Hono server with API routes
18- **database/**: SQLite database setup and queries
19- **routes/**: Modular route handlers
23- **index.html**: Main application shell
24- **components/**: React components for UI
25- **services/**: API communication and media handling
26- **utils/**: Client-side utilities
2730- **utils.ts**: Shared utility functions
3132## API Endpoints
3334- `POST /api/auth/login` - User login
35- `POST /api/auth/signup` - User registration
36- `POST /api/auth/logout` - User logout
37- `GET /api/auth/me` - Get current user
38- `POST /api/media/analyze` - Analyze uploaded media
39- `POST /api/media/search` - Search similar content
40- `GET /api/media/history` - Get user's analysis history
4142## Technology Stack
4344- **Backend**: Hono, SQLite, OpenAI API
45- **Frontend**: React, TailwindCSS
46- **AI/ML**: OpenAI GPT-4 Vision, Whisper
51521. Set up environment variables:
53- `OPENAI_API_KEY`: Your OpenAI API key
54- `JWT_SECRET`: Secret for JWT token signing
55
ProtoSharecontent.ts1 match
17}
1819// Middleware to check bearer token for API access
20async function requireBearerToken(c: any, next: any) {
21const authHeader = c.req.header("Authorization");
blog-3live-reload.ts1 match
82// if we wanted to create a /lastUpdatedAt route,
83// which would let us pass a val town bearer token, we could do that here
84// gives us 10k API requests per minute instead of 1k
85// and would work with private projects
86
blog-3get-old-posts.ts25 matches
19export const oldPosts: BlogPost[] = [
20{
21"title": "Solving the internal / external API riddle",
22"slug": "api-conundrum",
23"link": "/blog/api-conundrum",
24"description": "Figuring out how to provide an API that's usable by everyone and fast for us to iterate on",
25"pubDate": "Thu, 27 Mar 2025 00:00:00 GMT",
26"author": "Tom MacWright",
27},
28{
29"title": "API Tokens Scopes",
30"slug": "api-token-scopes",
31"link": "/blog/api-token-scopes",
32"description": "Improving security with granular control over permissions",
33"pubDate": "Fri, 01 Nov 2024 00:00:00 GMT",
59},
60{
61"title": "Expanding the Vals API - RFC",
62"slug": "expanding-the-vals-api-rfc",
63"link": "/blog/expanding-the-vals-api-rfc",
64"description": "Our REST API lets you do a lot - and soon it will enable more",
65"pubDate": "Fri, 30 Jun 2023 00:00:00 GMT",
66"author": "André Terron",
133},
134{
135"title": "The perks of a good OpenAPI spec",
136"slug": "openapi",
137"link": "/blog/openapi",
138"description": "Taking advantage of our typed REST API to build a platform around\nVal Town.",
139"pubDate": "Thu, 25 Jul 2024 00:00:00 GMT",
140"author": "Tom MacWright",
262},
263{
264"title": "The API we forgot to name",
265"slug": "the-api-we-forgot-to-name",
266"link": "/blog/the-api-we-forgot-to-name",
267"description": "An API that takes a Request and returns a Response - what was that, again?",
268"pubDate": "Thu, 19 Oct 2023 00:00:00 GMT",
269"author": "Steve Krouse",
286},
287{
288"title": "Deprecating the Run API",
289"slug": "deprecating-the-run-api",
290"link": "/blog/deprecating-the-run-api",
291"description": "Not every function should be an API",
292"pubDate": "Wed, 07 Feb 2024 00:00:00 GMT",
293"author": "André Terron",
321"slug": "val-town-newsletter-1",
322"link": "/blog/val-town-newsletter-1",
323"description": "Programmatic notifications, Hacker News API, and more.",
324"pubDate": "Wed, 04 Jan 2023 00:00:00 GMT",
325"author": "Steve Krouse",
450"slug": "val-town-newsletter-22",
451"link": "/blog/val-town-newsletter-22",
452"description": "Townie upgrades, Scoped API permissions, Fal partnership",
453"pubDate": "Mon, 02 Dec 2024 00:00:00 GMT",
454"author": "Steve Krouse",
blog-32025-05-23-glitch.md1 match
41going to promise that your Val Town projects will still work in the year 2500,
42because we both know that I'd be lying. Like Glitch, we've raised money from
43venture capital and it is currently what pays our paychecks and server bills.
44If it runs out and we haven't become profitable or found an acquirer, that'll
45be curtains.