Glancer_README.md1 match
1This directory has crons that extract data from Notion and save that data to blob storage in val.town. Blob storage functions like a cache.
23# demoCache.ts
Glancer_README.md2 matches
1The files in this directory export functions that get data from and save data to Notion. Most of these functions are used by /tasks.
23Every controller in this directory includes the Notion client:
20| Aspect | **Controller** | **Util** |
21| ----------------- | --------------------------------------------------- | --------------------------------------------------- |
22| **Purpose** | Orchestrates business logic and workflows | Provides small, stateless helper functions |
23| **Scope** | High-level, often involves services or side effects | Low-level, narrow in focus (e.g., string, date ops) |
24| **State** | Works with application or user-specific data | Stateless โ input in, output out |
Glancer_README.md4 matches
7### Task endpoints use /controllers to get and save data
89In order to keep the API easy to look and work with, the routes in /tasks handle routing but do not get data from or save data to Notion. The functions that connect to Notion live in the /controllers directory, and are _called_ from the endpoints in /tasks.
1011### Naming convention for routes and controllers
25Note that the export in the controller follows the same convention; it's also called `setDemoURL`.
26271. Once the controller is imported, pass data to the exported function so that it can do its thing:
2829```
31```
3233Note the function call is the exported function in the import object at the top of the route; i.e., `{ setDemoURL }`. The `setDemoURL.ts` controller exports it like this:
3435```
36// /controllers/setDemoURL.ts
37export async function setDemoURL(data: any) {
38try {
39...
Sketch_IdeasStylesViewer.tsx1 match
4import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
56export default function StylesViewer() {
7const [mediums, setMediums] = useState([]);
8const [loading, setLoading] = useState(true);
Sketch_IdeasApp.tsx1 match
4import StylesViewer from "./StylesViewer.tsx";
56export function App() {
7return (
8<div>
4import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
56export default function ColoursViewer() {
7const [palettes, setPalettes] = useState([]);
8const [loading, setLoading] = useState(true);
ReceiveSMSReceiveSMS.ts1 match
1export async function ReceiveSMS(req: Request): Promise<Response> {
2try {
3const bodyText = await req.text();
1export async function receiveSMS(req: Request) {
2// Parse incoming form data
3const form = await req.formData();
huyhieu.cursorrules12 matches
45- Ask clarifying questions when requirements are ambiguous
6- Provide complete, functional solutions rather than skeleton implementations
7- Test your logic against edge cases before presenting the final solution
8- Ensure all code follows Val Town's specific platform requirements
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
19- Follow modern ES6+ conventions and functional programming practices if possible
2021## Types of triggers
2829```ts
30export default async function (req: Request) {
31return new Response("Hello World");
32}
4243```ts
44export default async function () {
45// Scheduled task code
46}
5657```ts
58export default async function (email: Email) {
59// Process email
60}
66## Val Town Standard Libraries
6768Val Town provides several hosted services and utility functions.
6970### Blob Storage
120```
121122## Val Town Utility Functions
123124Val Town provides several utility functions to help with common project tasks.
125126### Importing Utilities
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
203โ โ โโโ README.md
204โ โโโ routes/ # Route modules
219โโโ shared/
220โโโ README.md
221โโโ utils.ts # Shared types and functions
222```
223226- 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:
229```ts
230import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
262- Export clear query functions with proper TypeScript typing
263264## Common Gotchas and Solutions
huyhieu.cursorrules12 matches
45- Ask clarifying questions when requirements are ambiguous
6- Provide complete, functional solutions rather than skeleton implementations
7- Test your logic against edge cases before presenting the final solution
8- Ensure all code follows Val Town's specific platform requirements
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
19- Follow modern ES6+ conventions and functional programming practices if possible
2021## Types of triggers
2829```ts
30export default async function (req: Request) {
31return new Response("Hello World");
32}
4243```ts
44export default async function () {
45// Scheduled task code
46}
5657```ts
58export default async function (email: Email) {
59// Process email
60}
66## Val Town Standard Libraries
6768Val Town provides several hosted services and utility functions.
6970### Blob Storage
120```
121122## Val Town Utility Functions
123124Val Town provides several utility functions to help with common project tasks.
125126### Importing Utilities
200โ โโโ database/
201โ โ โโโ migrations.ts # Schema definitions
202โ โ โโโ queries.ts # DB query functions
203โ โ โโโ README.md
204โ โโโ routes/ # Route modules
219โโโ shared/
220โโโ README.md
221โโโ utils.ts # Shared types and functions
222```
223226- 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:
229```ts
230import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
260- Run migrations on startup or comment out for performance
261- Change table names when modifying schemas rather than altering
262- Export clear query functions with proper TypeScript typing
263264## Common Gotchas and Solutions