FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
jessicaocean
jessicaoceanuntitled-1522
Public
Like
untitled-1522
Home
Code
5
backend
4
frontend
4
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
…
README.md

Backend

Hono-based API server with LastLogin authentication, SQLite database, and group chat functionality.

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 (with participant info)
  • GET /api/conversations/:id - Get specific conversation with messages
  • POST /api/conversations - Create new conversation
  • DELETE /api/conversations/:id - Delete conversation (admin only)

Group Chat Features

  • GET /api/conversations/:id/participants - Get conversation participants
  • POST /api/conversations/:id/invite - Invite user by email (admin only)
  • DELETE /api/conversations/:id/participants/:userId - Remove participant (admin only)

Invitations

  • GET /api/invites/:token - Get invitation details (public)
  • POST /api/invites/:token/accept - Accept invitation and join conversation

Chat & Real-time

  • POST /api/chat - Send message and get ChatGPT response
  • GET /api/conversations/:id/stream - Server-Sent Events for real-time updates

Database Schema

Core Tables

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

Group Chat Tables

  • conversation_participants_v1 - User-conversation relationships with roles
  • conversation_invites_v1 - Pending email invitations with tokens

Features

  • Automatic user creation on first login
  • Conversation history storage with full message history
  • ChatGPT integration via OpenAI API
  • Group chat functionality with role-based permissions
  • Email invitations with secure tokens
  • Real-time updates via Server-Sent Events
  • Secure user isolation - users can only access their conversations
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.