Run Your Own Codesfer Server
Deploy and manage your own Codesfer instance for complete control over your code snippets and data.
Server Setup
Get your Codesfer server up and running in seconds.
Start your Codesfer server with a single command.
Environment Variables
Configure your server with environment variables for flexible deployment.
Configure authentication and file index databases. Supports sqlite and libsql drivers.
How it works
Database configuration uses driver/source pairs. The *_DRIVER specifies the database type (sqlite or libsql), and *_SOURCE provides
the connection string.
| Variable | Description | Default |
|---|---|---|
DB_DRIVER | Auth database driver sqlite libsql | sqlite |
DB_SOURCE | Auth database connection string | file:auth.db |
INDEX_DB_DRIVER | File index database driver sqlite libsql | sqlite |
INDEX_DB_SOURCE | File index database connection string | file:index.db |
OBJECT_BACKEND_DRIVER | Object storage backend sqlite r2 | sqlite |
OBJECT_STORAGE_SOURCE | Object storage connection string (when OBJECT_BACKEND_DRIVER=sqlite) | file:object_storage.db |
Required when using OBJECT_BACKEND_DRIVER=r2
| Variable | Description |
|---|---|
CF_ACCOUNT_ID | Your Cloudflare Account ID |
CF_ACCESS_KEY | R2 Access Key ID |
CF_SECRET_ACCESS_KEY | R2 Secret Access Key |
CF_BUCKET | R2 Bucket Name |
Example Configurations
Ready-to-use configuration examples for different deployment scenarios.
Simple setup for personal use or development.
export DB_DRIVER="sqlite"
export DB_SOURCE="file:auth.db"
export INDEX_DB_DRIVER="sqlite"
export INDEX_DB_SOURCE="file:index.db"
export OBJECT_BACKEND_DRIVER="sqlite"
export OBJECT_STORAGE_SOURCE="file:object_storage.db"
./build/codeserver -port 3000Production setup with scalable cloud storage.
export DB_DRIVER="sqlite"
export DB_SOURCE="file:auth.db"
export INDEX_DB_DRIVER="sqlite"
export INDEX_DB_SOURCE="file:index.db"
export OBJECT_BACKEND_DRIVER="r2"
export CF_ACCOUNT_ID="your-account-id"
export CF_ACCESS_KEY="your-access-key"
export CF_SECRET_ACCESS_KEY="your-secret-key"
export CF_BUCKET="your-bucket-name"
./build/codeserver -port 3000Distributed database with Turso and R2 object storage.
export DB_DRIVER="libsql"
export DB_SOURCE="libsql://your-database.turso.io?authToken=your-auth-token"
export INDEX_DB_DRIVER="libsql"
export INDEX_DB_SOURCE="libsql://your-index-db.turso.io?authToken=your-auth-token"
export OBJECT_BACKEND_DRIVER="r2"
export CF_ACCOUNT_ID="your-account-id"
export CF_ACCESS_KEY="your-access-key"
export CF_SECRET_ACCESS_KEY="your-secret-key"
export CF_BUCKET="your-bucket-name"
./build/codeserver -port 3000REST API Endpoints
Build custom integrations using the exposed REST API.
The server exposes these endpoints for authentication and storage management.
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/login | Authenticate user |
| GET | /storage/list | List user's snippets |
| POST | /storage/upload | Upload a new snippet |
| DELETE | /storage/remove | Remove a snippet |