• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
Jamesllllllllll

Jamesllllllllll

like-anything

Add a "Like" button anywhere on the web
Remix of maxm/ipv4-counter
Public
Like
like-anything
Home
Code
9
.claude
1
backend
1
frontend
1
.vtignore
CLAUDE.md
PAGE_LIKES_DOCUMENTATION.md
README.md
deno.json
H
index.ts
Branches
1
Pull requests
Remixes
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
CLAUDE.md
Code
/
CLAUDE.md
Search
8/10/2025
Viewing readonly version of main branch: v14
View latest version
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Architecture Overview

This is a Val Town project that implements a cross-origin likes tracking API with the following structure:

  • Val Town Platform: Built specifically for Val Town's serverless environment using Deno runtime
  • Backend: Hono web framework with SQLite database for likes tracking across multiple websites
  • API Service: RESTful endpoints with CORS support for cross-origin requests
  • Entry Point: index.ts exports app.fetch as the HTTP handler

Key Components

Backend (backend/database.ts)

  • Uses Val Town's hosted SQLite service (stevekrouse/sqlite)
  • Table versioning pattern: website_likes_v1 (increment version when changing schema)
  • Core functions: initDatabase(), recordLike(), getAllLikes(), getLikeCount(), getTotalLikes()
  • Database tracks likes by website and optional page URL
  • Database initializes automatically on startup

API Documentation Page (/ route)

  • Self-contained HTML documentation page
  • Shows API endpoints and usage examples
  • No longer a tracking frontend, just documentation

Main Application (index.ts)

  • Hono app with error unwrapping for debugging and CORS support
  • Routes: / (API docs), POST /api/like (record like), GET /api/likes/:website (get count), GET /api/likes (all data)
  • Accepts JSON payloads with website and optional pageUrl
  • Returns updated like counts for real-time UI updates

Common Development Commands

# Run/test the application locally deno run --allow-net --allow-read index.ts # Lint code deno lint # Format code deno fmt # Type checking deno check index.ts

Val Town Specific Patterns

Database Schema Changes

When modifying the database schema, increment the table name (e.g., website_likes_v1 → website_likes_v2) rather than using ALTER TABLE operations.

API Usage

The API is designed for cross-origin requests. Example usage from any website:

fetch('https://your-val-url.val.run/api/like', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ website: 'mysite.com', pageUrl: window.location.pathname }) }) .then(res => res.json()) .then(data => console.log('New like count:', data.likeCount));

File Serving

Uses Val Town utility functions for proper file serving:

import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";

Error Handling

Include this pattern in Hono apps for better error visibility:

app.onError((err, c) => { throw err; });

CORS Configuration

The API includes CORS headers to allow requests from any origin:

app.use('*', cors({ origin: '*', allowMethods: ['GET', 'POST', 'OPTIONS'], allowHeaders: ['Content-Type'], }));

Configuration Notes

  • TypeScript: Configured with relaxed settings (noImplicitAny: false, strict: false)
  • Imports: Uses https://esm.sh for npm packages and https://esm.town/v/ for Val Town utilities
  • Styling: TailwindCSS via CDN script tag
  • Error Debugging: Includes <script src="https://esm.town/v/std/catch"></script> for client-side error capture
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.