GlancerdemoCobrowseStatus.ts1 match
11// this cron updates a blob that the ../../shared/utils/pollEnabledStatus.ts hits during demos
12// that blob determines whether or not the cobrowsing button is ON or OFF
13export default async function (interval: Interval) {
14// every page in the "Glancer demos" database should have it's own blob, so we have a cache for each demo
15// this cron saves a blob for every page in the Demos DB
GlancerdemoCache.ts1 match
9});
1011export default async function (interval: Interval) {
12// this cron runs every minute
13// it saves a blob for every page in the "Glancer demos" database
6});
78export async function getDatabase(databaseId: string) {
9// get database
10try {
Glancer.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
6});
78export async function setCobrowse(pageId: string, cobrowse: boolean) {
9try {
10const page = await notion.pages.update({
1export async function blobKeyForHealthCheck() {
2// get the url of this file
3// we'll use this to get values for the blob key
1export async function blobKeyForDemoCobrowseStatus(id: string) {
2// get the url of this file
3// we'll use this to get values for the blob key
1export async function blobKeyForDemoCache(id: string) {
2// get the url of this file
3// we'll use this to get values for the blob key
14}
15// Simple hook for mobile menu toggle
16function useMobileMenu() {
17const [isOpen, setIsOpen] = useState(false);
18const toggleMenu = () => setIsOpen(!isOpen);
2223// Simple hook for tracking current hash for active nav styling
24function useCurrentHash() {
25const [currentHash, setCurrentHash] = useState(() =>
26window.location.hash.slice(1)
39}
4041export function App({ initialData }: AppProps) {
42// initialData
43const { demoData, loading, error } = initialData;
Glanceragent.controller.ts1 match
6});
78export async function enrichAgent(pageId: string, data: any) {
9// console.log(data);
10const properties =