fc-gamesSearchScreen.tsx1 match
53onChange={(e) => setQuery(e.target.value)}
54placeholder="@user, fid:123, /channel, cast hash"
55// autoCapitalize="on"
56// autoCorrect="on"
57type="text"
12- Farcaster mini app manifest + webhook + embed metadata
13- Farcaster notifications (storing tokens, sending recurring notifications, ...)
14- Neynar API integration for Farcaster data
1516
1const baseUrl = 'https://sonar.val.run/neynar-proxy?path='
2// const baseUrl = "https://api.neynar.com/v2/farcaster/";
34export async function fetchNeynarGet(path: string) {
8'Content-Type': 'application/json',
9'x-neynar-experimental': 'true',
10'x-api-key': 'NEYNAR_API_DOCS',
11},
12})
1const NEYNAR_API_KEY = Deno.env.get('NEYNAR_API_KEY') || 'NEYNAR_API_DOCS'
2const headers = {
3'Content-Type': 'application/json',
4'x-neynar-experimental': 'true',
5'x-api-key': NEYNAR_API_KEY,
6}
78export const fetchNeynarGet = async (path: string) => {
9return await fetch('https://api.neynar.com/v2/farcaster/' + path, {
10method: 'GET',
11headers: headers,
1415export const fetchNeynarPost = async (path: string, body: any) => {
16return await fetch('https://api.neynar.com/v2/farcaster/' + path, {
17method: 'POST',
18headers: headers,
109110export function fetchStarterPackMemberIds(id: string) {
111return fetch(`https://api.warpcast.com/fc/starter-pack-members?id=${id}`)
112.then((res) => res.json())
113.then((data) => data?.result?.members)
115116export function fetchTrendingUsers() {
117return fetchProxyJSON(`https://api.farcaster.xyz/v1/creator-rewards-winner-history?limit=100`)
118.then((data) => data?.result?.history?.winners)
119.then((users) => users.map((u) => u.fid))
17export async function trending() {
18return await fetch(
19`https://api.giphy.com/v1/gifs/trending?api_key=${
20Deno.env.get('GIPHY_API_KEY')
21}&limit=100`,
22).then((r) => r.json())
24export async function search(q: string) {
25return await fetch(
26`https://api.giphy.com/v1/gifs/search?q=${q}&api_key=${
27Deno.env.get('GIPHY_API_KEY')
28}&limit=100`,
29).then((r) => r.json())
fc-games.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`
120notifications, ...)
121</div>
122<div className=''>✷ Neynar API integration for Farcaster data</div>
123<div className=''>
124✷ Hosted on Val Town (instant deployments on save)
4546useEffect(() => {
47fetch("/api/posts").then((ok) => ok.json())
48.then((posts) => setPosts(posts));
49}, []);
6364export default async function server(req: Request): Promise<Response> {
65if (req.url.endsWith("/api/posts")) {
66const posts = await fetchAllReddits();
67posts.sort((a, b) => b.score - a.score);
1// DeepInfra OpenAI API 转发服务
2import { fetch } from "https://esm.town/v/std/fetch";
317const path = url.pathname;
18
19// 构建DeepInfra API URL
20// 将 /v1/chat/completions 转换为 /v1/openai/chat/completions
21let deepinfraPath = path;
24}
25
26const deepinfraUrl = `https://api.deepinfra.com${deepinfraPath}`;
27
28// 获取请求体