thirdTimerval-town.mdc9 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:
163- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
164- **Storage:** DO NOT use the Deno KV module for storage
165- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
166- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
167- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
168- **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
169- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
170- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
171- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
205### Backend (Hono) Best Practices
206207- Hono is the recommended API framework
208- Main entry point should be `backend/index.ts`
209- Do NOT use Hono serveStatic middleware
230});
231```
232- Create RESTful API routes for CRUD operations
233- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
234```ts
267- For files in the project, use `readFile` helpers
2682695. **API Design:**
270- `fetch` handler is the entry point for HTTP vals
271- Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
ReactHonoStarterTestsindex.ts2 matches
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
1314// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
1617// Unwrap and rethrow Hono errors as the original error
uppsalatech25data.ts4 matches
7});
8type Message = z.infer<typeof messageSchema>;
9type MessageWithSource = Message & { source: "email" | "sms" | "api" };
10export async function getMessages(): Promise<MessageWithSource[]> {
11let messages = await blob.getJSON(key);
19return addMessage({ message: email.text, subject: email.subject }, "email");
20}
21export async function addApiMessage(apiMessage: unknown) {
22return addMessage(apiMessage, "api");
23}
24export async function addSms(sms: unknown) {
27async function addMessage(
28message: unknown,
29source: "sms" | "email" | "api",
30): Promise<Message | null> {
31const allMessages = await getMessages();
uppsalatech25api.tsx2 matches
1import { Hono } from "npm:hono@4";
2import { getConnInfo } from "npm:hono@4/cloudflare-workers";
3import { addApiMessage, addSms, getMessages } from "./data.ts";
4import { verifyElks } from "./verify.tsx";
514app.post("/message", async (c) => {
15const body = await c.req.json();
16const message = await addApiMessage(body);
17if (!message) {
18c.status(400);
templateTwitterAlertREADME.md4 matches
31Refer to [Twitter's search operators](https://socialdata.gitbook.io/docs/twitter-tweets/retrieve-search-results-by-keyword#endpoint-parameters) to fine-tune your query.
3233### 4. Test API call
34Set `isProd = false` in the code if you are testing, to ensure there are enough tweets to display. <br>
35Toggle it back to `true` when you're ready to run this cron job in production and actuall send notifications.
6061### NOTE: Usage Limits
62This val uses the SocialData API for Twitter data:
6364- **Proxies via Val Town's [SocialDataProxy](https://www.val.town/v/stevekrouse/socialDataProxy)**: Limited to 10 cents per day for [**Val Town Pro users**](https://www.val.town/pricing). This API is *only* for Pro users.
65- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.
uppsalatech25README.md1 match
34## HTTP
5Hono API with
6- `GET` route for all message
7. `POST` route for sending a message
simulationcontacts.http.ts2 matches
202});
203204// Root endpoint with API documentation
205app.get('/', (c) => {
206return c.json({
207message: 'Contacts API',
208endpoints: {
209'POST /contacts': 'Create or update a contact (name, address, zipcode, phone_number)',
78// Import route modules
9import api from "./routes/api/api.ts";
10import auth from "./routes/auth.ts";
11import root from "./routes/root.ts";
3435// Mount route modules
36app.route("/api", api);
37app.route("/tasks", tasks);
38app.route("/demo", demo);
1import { Hono } from "npm:hono";
23// Import route modules
4import cobrowse from "./cobrowse.ts";
5import database from "./database.ts";
GlancergettingStarted.tsx1 match
27}}
28>
29<h3 className="font-bold capitalize">
30{item?.properties?.Name?.title?.[0]?.plain_text}
31</h3>