Files
Charon/backend/internal/database/database.go
Wikid82 b9dcc6c347 feat(backend): implement database schema, models, and import workflow
- Add ProxyHost, CaddyConfig, RemoteServer, SSL, AccessList, User, Setting, ImportSession models
- Implement ProxyHostService and RemoteServerService with domain/name uniqueness validation
- Add Caddyfile import handler with conflict detection and user review workflow
- Create ProxyHostHandler and RemoteServerHandler with full CRUD operations
- Wire up Gin/GORM/SQLite dependencies and create missing internal packages
- Add database connection layer, server routing, and version info
- Update routes to register all new handlers and auto-migrate models
- Configure import environment variables and mount points

Addresses Issue #5 (data persistence) and Issue #43 (remote servers)
Backend now compiles cleanly with go build
2025-11-18 11:09:10 -05:00

19 lines
323 B
Go

package database
import (
"fmt"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
// Connect opens a SQLite database connection.
func Connect(dbPath string) (*gorm.DB, error) {
db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
if err != nil {
return nil, fmt.Errorf("open database: %w", err)
}
return db, nil
}