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

fxfr

flixdb

Unlisted
Like
flixdb
Home
Code
4
backend
4
frontend
4
shared
2
README.md
Branches
2
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
/
backend
/
README.md
Code
/
backend
/
README.md
Search
7/23/2025
README.md

Backend API

Hono-based API server that provides authentication and CRUD operations for notes and receipts using PocketBase.

Architecture

The backend uses a generic CRUD factory pattern to eliminate code duplication between similar resources:

  • crud-factory.ts - Generic CRUD route factory
  • resource-configs.ts - Resource-specific configurations for notes and receipts
  • index.ts - Main application setup and auth routes

Environment Variables

  • POCKETBASE_URL - Your PocketBase instance URL

API Endpoints

Authentication

  • POST /api/auth/login - Login with email/password
  • POST /api/auth/logout - Logout (requires auth)
  • GET /api/auth/me - Get current user info (requires auth)

Notes

  • GET /api/notes - Get all notes for authenticated user
  • POST /api/notes - Create a new note
  • PUT /api/notes/:id - Update a note
  • DELETE /api/notes/:id - Delete a note (hard delete)

Receipts

  • GET /api/receipts - Get all non-trashed receipts for authenticated user
  • POST /api/receipts - Create a new receipt
  • PUT /api/receipts/:id - Update a receipt
  • DELETE /api/receipts/:id - Delete a receipt (soft delete - sets trashed=true)

All resource endpoints require authentication via Bearer token in Authorization header.

Adding New Resources

To add a new resource type (e.g., tasks, bookmarks):

  1. Define the TypeScript types in shared/types.ts
  2. Create a resource configuration in resource-configs.ts
  3. Add the CRUD routes in index.ts using createCrudRoutes()

Example:

Create val
// In resource-configs.ts export const tasksConfig: ResourceConfig<Task, CreateTaskRequest, UpdateTaskRequest> = { collectionName: "tasks", mapRecord: (record: any): Task => ({ /* mapping logic */ }), createData: (req: CreateTaskRequest) => ({ /* create data */ }), updateData: (req: UpdateTaskRequest) => ({ /* update data */ }), }; // In index.ts createCrudRoutes(app, "/tasks", tasksConfig, pb, requireAuth);

Static Files

  • / - Serves the main HTML page
  • /notes - Serves the notes page
  • /receipts - Serves the receipts page
  • /frontend/* - Serves frontend React components
  • /shared/* - Serves shared TypeScript types
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.