markdown-embeddemoCache.ts1 match
5// Initialize Notion client
6const notion = new Client({
7auth: Deno.env.get("NOTION_API_KEY"),
8});
9
markdown-embed.cursorrules10 matches
13- Generate code in TypeScript or TSX
14- Add appropriate TypeScript types and interfaces for all data structures
15- Prefer official SDKs or libraries than writing API calls directly
16- Ask the user to supply API or library documentation if you are at all unsure about it
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
23### 1. HTTP Trigger
2425- Create web APIs and endpoints
26- Handle HTTP requests and responses
27- Example structure:
173However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
174If 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
175or by making an API request for it.
176177## Val Town Platform Specifics
181- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
182- **Storage:** DO NOT use the Deno KV module for storage
183- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
184- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
185- **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
186- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
187- **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
188- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
189- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
190- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
224### Backend (Hono) Best Practices
225226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
248});
249```
250- Create RESTful API routes for CRUD operations
251- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
252```ts
285- For files in the project, use `readFile` helpers
2862875. **API Design:**
288- `fetch` handler is the entry point for HTTP vals
289- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
markdown-embedchess.tsx3 matches
10// src="https://glance--90537b2ecab54268bf831875fe1d0158.web.val.run"
11// src="https://lightweight--ef4179e03fc011f0bc0c76b3cceeab13.web.val.run"
12// src="/api/iframe"
13// src={`/api/${content}`}
14// src={`/api/${content}?user=${userId}`}
15src={contentURL}
16title={`Glance content: ${content}`}
markdown-embedauth.ts4 matches
1export default async (c, next) => {
2const method = c.req.method;
3const secret = c.req.header("x-api-key"); // sent by Notion webhooks via POST
4const fetchSite = c.req.header("sec-fetch-site");
56// POSTs from Notion are automation webhooks that carry the x-api-key custom header
7// that header needs to match the X_API_KEY environment variable in this project
8// or this auth check won't pass
9// for now we can just let GETs through without any auth shim
10if (
11(secret && secret !== Deno.env.get("X_API_KEY") || fetchSite && fetchSite !== "same-origin") && method !== "GET"
12) {
13console.log(fetchSite);
markdown-embedApp.tsx5 matches
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { useEffect, useState } from "https://esm.sh/react@18.2.0";
3import { DemoData, isApiError, isNotionPage } from "../index.tsx";
4import { CheckoutContent } from "./content/checkout/checkout.tsx";
5import { FormContent } from "./content/form/form.tsx";
60if (!demoData) return <div>No demo data available</div>;
6162// Handle error responses from the API
63if (isApiError(demoData)) {
64return (
65<div>
66<h3>API Response:</h3>
67<p>
68<strong>Status:</strong> {demoData.status}
168href={`#${page.properties.Name.title[0].plain_text}`}
169className={
170`${currentHash === page.properties.Name.title[0].plain_text ? 'active' : ''} capitalize`
171}
172onClick={() => {
markdown-embedapi.ts0 matches
1import { Hono } from "npm:hono";
23// Import route modules
4import cobrowse from "./cobrowse.ts";
5import database from "./database.ts";
23const GIGYA_DOMAIN = process.env.GIGYA_DOMAIN || "accounts.eu1.gigya.com";
4const GIGYA_API_KEY = process.env.GIGYA_API_KEY;
5const GIGYA_APP_KEY = process.env.GIGYA_APP_KEY;
6const GIGYA_APP_SECRET = process.env.GIGYA_APP_SECRET;
78if (!GIGYA_API_KEY || !GIGYA_APP_KEY || !GIGYA_APP_SECRET) {
9console.error("Missing Gigya environment variables!");
10console.log("Required variables: GIGYA_API_KEY, GIGYA_APP_KEY, GIGYA_APP_SECRET");
11process.exit(1);
12}
1617const body = new URLSearchParams({
18apiKey: GIGYA_API_KEY,
19userKey: GIGYA_APP_KEY,
20secret: GIGYA_APP_SECRET,
123}
124125// 5. Test connection to accounts API
126console.log("\n5. Testing accounts API connection...");
127try {
128const testResponse = await makeGigyaRequest("accounts.getAccountInfo", {
130});
131132// We expect this to fail with "user not found" which means the API is working
133if (testResponse.errorCode === 403005) {
134console.log("✅ Accounts API connection working (user not found as expected)");
135} else {
136console.log(`⚠️ Unexpected accounts API response: ${testResponse.errorMessage}`);
137}
138} catch (error) {
139console.log("❌ Accounts API connection failed:", error.message);
140}
141
osds-schema.ts4 matches
23const GIGYA_DOMAIN = process.env.GIGYA_DOMAIN || "accounts.eu1.gigya.com";
4const GIGYA_API_KEY = process.env.GIGYA_API_KEY;
5const GIGYA_APP_KEY = process.env.GIGYA_APP_KEY;
6const GIGYA_APP_SECRET = process.env.GIGYA_APP_SECRET;
78if (!GIGYA_API_KEY || !GIGYA_APP_KEY || !GIGYA_APP_SECRET) {
9console.error("Missing Gigya environment variables!");
10console.log("Required variables: GIGYA_API_KEY, GIGYA_APP_KEY, GIGYA_APP_SECRET");
11process.exit(1);
12}
1617const body = new URLSearchParams({
18apiKey: GIGYA_API_KEY,
19userKey: GIGYA_APP_KEY,
20secret: GIGYA_APP_SECRET,
FarcasterSpacesSpace.tsx2 matches
139140const queryFn = () =>
141fetch(`/api/channels`)
142.then((r) => r.json())
143.then((r) => r?.data?.channels?.find((c) => c.channel_name == channel))
146147const join = async () => {
148const response = await fetch(`/api/token?channel=${channel}&uid=${uid}`).then((r) => r.json())
149console.log('response', response)
150setToken(response.token)