/mini-chffr

Primary LanguageTypeScript

mini-chffr

A self-hostable openpilot data backend built with Bun, TypeScript, and SQLite.

Implementation Notes

Database & Models:

  • SQLite database with bun:sqlite (native, fast, no ORM needed)
  • User and Device models with static methods for database operations
  • WAL mode enabled for better performance

API Endpoints:

  • GET /v1/me - Returns authenticated user info
  • GET /v1/me/devices - Returns user's devices
  • GET /v1.1/devices/:dongleId - Returns specific device info
  • GET /auth/login/:provider - OAuth login (Google/GitHub redirects)
  • GET /auth/callback/:provider - OAuth callback handler

Features:

  • Bearer token authentication (user ID as token for now)
  • Proper error handling (401, 404, 400 responses)
  • TypeScript with full type safety
  • Comprehensive test suite (8 tests, all passing)
  • Hot reload development server

Getting Started

To install dependencies:

bun install

Set up environment variables:

cp .env.example .env

Update .env with your OAuth client IDs:

  • GOOGLE_CLIENT_ID: Your Google OAuth client ID
  • GITHUB_CLIENT_ID: Your GitHub OAuth client ID

To run:

bun --hot index.ts    # Start server
./test.sh             # Run full test suite

Status: Backend is ready for web app integration. OAuth still needs actual token exchange implementation, and you'll need to add proper JWT tokens and device registration endpoints when ready to connect openpilot devices.