client-generatorindex.html1 match
32id="message"
33rows="4"
34placeholder="What is the capital of France?"
35class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
36></textarea>
client-generatorREADME.md3 matches
45- Static file serving for the frontend
6- API routing for GPT wrapper functionality
7- Dynamic importing of external Val Town modules
81011- `index.ts` - Main entry point with Hono app setup
12- `routes/serveGptWrapper.tsx` - GPT wrapper API endpoint
1314## API Design
1516The backend follows RESTful principles and includes proper error handling with full stack traces for debugging.
client-generatorknowledge.md14 matches
14- Generate code in TypeScript or TSX
15- Add appropriate TypeScript types and interfaces for all data structures
16- Prefer official SDKs or libraries than writing API calls directly
17- Ask the user to supply API or library documentation if you are at all unsure about it
18- **Never bake in secrets into the code** - always use environment variables
19- Include comments explaining complex logic (avoid commenting obvious operations)
24### 1. HTTP Trigger
2526- Create web APIs and endpoints
27- Handle HTTP requests and responses
28- Example structure:
135## GreenPTClient
136137The `GreenPTClient` is a function that allows interaction with the GreenPT API for chat completions. It accepts a model parameter and provides an `invoke` method to send messages and retrieve responses asynchronously. To ensure API security, it requires an API key stored in environment variables.
138139### Example Usage
146async function getChatResponse() {
147const messages = [
148{ role: "user", content: "What is the capital of France?" },
149];
150153console.log("AI Response:", response);
154} catch (error) {
155console.error("Error invoking GreenPT API:", error);
156}
157}
161```
162163In this example, we create an instance of `GreenPTClient`, send a message asking about the capital of France, and log the AI's response. Error handling is included to catch any issues with the API call.
164165228However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
229If 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
230or by making an API request for it.
231232## Val Town Platform Specifics
236- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
237- **Storage:** DO NOT use the Deno KV module for storage
238- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
239- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
240- **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
241- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
242- **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
243- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
244- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
245- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
279### Backend (Hono) Best Practices
280281- Hono is the recommended API framework
282- Main entry point should be `backend/index.ts`
283- **Static asset serving:** Use the utility functions to read and serve project files:
303});
304```
305- Create RESTful API routes for CRUD operations
306- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
307```ts
340- For files in the project, use `readFile` helpers
3413425. **API Design:**
343- `fetch` handler is the entry point for HTTP vals
344- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
124const shape = c.req.query('shape') ?? 'rect'
125const showLabel = c.req.query('label') !== 'false' // Default to showing label
126// Map stat types to labels and API statistic names
127const statMap = {
128download: { label: 'downloads', apiStat: 'install' },
129install: { label: 'installs', apiStat: 'install' },
130rating: { label: 'rating', apiStat: 'averagerating' }
131}
132
159}
160
161// Fetch stats from VS Marketplace API
162try {
163// Use the correct VS Marketplace Gallery API with POST method
164const apiUrl = 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery'
165console.log('Fetching extension stats for:', namespace)
166
179}
180
181const response = await fetch(apiUrl, {
182method: 'POST',
183headers: {
184Accept: 'application/json;api-version=6.0-preview.1',
185'Content-Type': 'application/json',
186'User-Agent': 'HuyHieu Badge Service'
197
198const data = await response.json()
199console.log('API Response structure:', Object.keys(data))
200
201const extensions = data.results?.[0]?.extensions
202if (!extensions || extensions.length === 0) {
203console.warn('No extensions found in API response')
204statValue = 'ExtensionNotFound'
205}
206
207const extension = extensions[0]
208const targetStat = extension.statistics?.find(stat => stat.statisticName === statConfig.apiStat)
209let statValue = targetStat?.value
210if (!targetStat) {
211console.log(`Statistic '${statConfig.apiStat}' not found. Available:`, extension.statistics?.map(s => s.statisticName))
212statValue = 0
213}
houseCommitteeMeetingQuickCheckdata.js12 matches
2import { sqlite } from "https://esm.town/v/std/sqlite";
34const api_key = Deno.env.get("GPO_API_KEY");
5const date = new Date();
6const current_congress = (date.getFullYear() - 1789) / 2 + 1;
7const cdg_api_base_url = `https://api.congress.gov/v3/committee-meeting/${current_congress}/house`;
8const cdg_base_url = `https://www.congress.gov/event/${current_congress}/house`;
9const house_repo_base_url = "https://docs.house.gov/Committee/Calendar/ByEvent.aspx?EventID=";
2728for (let eventId of eventIds) {
29const cdg_api_url = `${cdg_api_base_url}/${eventId}?api_key=${api_key}&format=json`;
30const cdg_api_url_xml_priv = `${cdg_api_base_url}/${eventId}?api_key=${api_key}&format=xml`;
31const cdg_api_url_json = `${cdg_api_base_url}/${eventId}?api_key=DEMO_KEY&format=json`;
32const cdg_api_url_xml = `${cdg_api_base_url}/${eventId}?api_key=DEMO_KEY&format=xml`;
33const cdg_url = `${cdg_base_url}/${eventId}`;
34const house_repo_url = `${house_repo_base_url}${eventId}`;
35const json_resp = await fetch(cdg_api_url);
36const xml_resp = await fetch(cdg_api_url_xml_priv);
37await sqlite.execute({
38sql:
39`insert into meetings(event_id, cdg_api_url_json, cdg_json_status, cdg_api_url_xml, cdg_xml_status, cdg_url, house_repo_url)
40values (:event_id, :cdg_api_url_json, :cdg_json_status, :cdg_api_url_xml, :cdg_xml_status, :cdg_url, :house_repo_url)`,
41args: {
42event_id: eventId,
43cdg_api_url_json: cdg_api_url_json,
44cdg_json_status: json_resp.status,
45cdg_api_url_xml: cdg_api_url_xml,
46cdg_xml_status: xml_resp.status,
47cdg_url: cdg_url,
mouthyindex.html1 match
506let currentVisemeTransitionTimeout; // Manages the sequence of intermediate visemes
507508// Web Speech API setup
509const speechUtterance = new SpeechSynthesisUtterance();
510const synth = window.speechSynthesis;
client-generatormain.tsx1 match
129}
130131// Handle API requests on POST
132if (req.method !== "POST") {
133return new Response("Method not allowed", { status: 405 });
create-safehash-serverclient.tsx20 matches
266// === Payment Variables (Easily Visible) ===
267const [credentials, setCredentials] = useState({
268apikey: 'a',
269username: 'b',
270password: 'p',
327328const areCredentialsComplete = () => {
329return credentials.apikey && credentials.username && credentials.password;
330};
331353setTimestamp(ts);
354355// Use page nonce from meta tag (no API fallback for security)
356if (!metaNonce) {
357setPayError('Security error: No payment nonce found. Please refresh the page and try again.');
380let hash = '';
381try {
382const hashEndpoint = \`\${SERVER_URL}/api/create-payment-hash\`;
383const apiResponse = await fetch(hashEndpoint, {
384method: 'POST',
385headers: {
391credentials: 'include', // For cookies
392body: JSON.stringify({
393apikey: credentials.apikey,
394username: credentials.username,
395password: credentials.password,
401});
402
403if (!apiResponse.ok) {
404const errorText = await apiResponse.text();
405let errorMsg;
406try {
407const errorData = JSON.parse(errorText);
408errorMsg = errorData.error || 'Hash API failed';
409} catch {
410errorMsg = 'Hash API returned ' + apiResponse.status;
411}
412throw new Error(errorMsg);
413}
414
415hash = await apiResponse.text();
416logDebug({ type: 'hash-response', response: hash });
417} catch (err) {
418const msg = err instanceof Error ? err.message : String(err);
419setPayError('Hash API failed: ' + msg);
420logDebug({ type: 'error', error: 'Hash API failed: ' + msg });
421setIsProcessing(false);
422return;
428url: 'https://payuat.travelpay.com.au/online/v5',
429merchantCode,
430apiKey: credentials.apikey,
431fingerprint: hash,
432redirectUrl: window.location.href,
485key: 'cred-title',
486className: "text-xl font-semibold mb-3"
487}, 'API Credentials'),
488React.createElement(Input, {
489key: 'apikey',
490label: "API Key",
491name: "apikey",
492value: credentials.apikey,
493onChange: handleCredentialChange,
494className: "mb-3"
565key: 'tours-disabled-msg',
566className: "text-sm text-gray-600 mb-3"
567}, 'Please enter API credentials to enable tour selection'),
568...tours.map((tour) =>
569React.createElement(Card, {
lumalabs-starterREADME.md3 matches
5## Files
67- `types.ts` - TypeScript interfaces for API requests/responses and Luma AI data structures
89## Types
1011- `VideoGeneration` - Complete video generation object from Luma AI API
12- `GenerationRequest` - Request payload for creating new generations
13- `GenerationResponse` - Standardized API response wrapper
lumalabs-starterREADME.md5 matches
1# Backend
23Hono-based API server for Luma AI video generation.
45## API Endpoints
67### POST /api/generate
8Creates a new video generation request.
928```
2930### GET /api/generation/:id
31Gets the status and details of a video generation.
3250## Environment Variables
5152- `LUMAAI_API_KEY` - Required. Your Luma AI API key
5354## Static File Serving