FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
jessicaocean
jessicaoceanuntitled-1522
Public
Like
untitled-1522
Home
Code
5
backend
4
frontend
3
shared
1
README.md
main.ts
Branches
1
Pull requests
Remixes
History
Environment variables
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
…
Viewing readonly version of main branch: v15
View latest version
README.md

Backend

Hono-based API server with LastLogin authentication and SQLite database.

Structure

  • index.ts - Main HTTP handler with LastLogin wrapper
  • database/ - Database migrations and query functions
  • routes/ - API route handlers

API Endpoints

Authentication

  • All API routes require authentication via LastLogin
  • User email is extracted from X-LastLogin-Email header

Conversations

  • GET /api/conversations - Get user's conversations
  • GET /api/conversations/:id - Get specific conversation with messages
  • POST /api/conversations - Create new conversation
  • DELETE /api/conversations/:id - Delete conversation

Chat

  • POST /api/chat - Send message and get ChatGPT response

Database Schema

Tables

  • chat_users_v1 - User accounts
  • chat_conversations_v1 - Conversation metadata
  • chat_messages_v1 - Individual messages

Features

  • Automatic user creation on first login
  • Conversation history storage
  • ChatGPT integration via OpenAI API
  • Secure user isolation (users can only access their own data)
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.