Switch to modernc.org/sqlite and update dockerfile
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"quay/app/repository"
|
||||
|
||||
"github.com/google/uuid"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
type SQLiteSiteRepository struct {
|
||||
|
||||
@@ -3,11 +3,11 @@ package database
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
func ConnectSQLite(dbPath string) (*sql.DB, error) {
|
||||
db, err := sql.Open("sqlite3", dbPath+"?_busy_timeout=5000&_journal_mode=WAL")
|
||||
db, err := sql.Open("sqlite", dbPath+"?_busy_timeout=5000&_journal_mode=WAL")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ import (
|
||||
"quay/app/repository"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/mattn/go-sqlite3"
|
||||
"modernc.org/sqlite"
|
||||
sqlite3 "modernc.org/sqlite/lib"
|
||||
)
|
||||
|
||||
type SQLiteUserRepository struct {
|
||||
@@ -149,10 +150,9 @@ func (r *SQLiteUserRepository) AdminUserExists() (bool, error) {
|
||||
}
|
||||
|
||||
func isSQLiteUniqueConstraintError(err error) bool {
|
||||
var sqliteErr sqlite3.Error
|
||||
var sqliteErr *sqlite.Error
|
||||
if !errors.As(err, &sqliteErr) {
|
||||
return false
|
||||
}
|
||||
|
||||
return sqliteErr.Code == sqlite3.ErrConstraint && sqliteErr.ExtendedCode == sqlite3.ErrConstraintUnique
|
||||
return sqliteErr.Code() == sqlite3.SQLITE_CONSTRAINT_UNIQUE
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@ import (
|
||||
)
|
||||
|
||||
type EnvConfig struct {
|
||||
Port string
|
||||
ConfigDir string
|
||||
GithubPat string
|
||||
StoragePath string
|
||||
DashboardHost string
|
||||
Port string
|
||||
ConfigDir string
|
||||
GithubPat string
|
||||
StoragePath string
|
||||
DashboardHost string
|
||||
StaticDashboardPath string
|
||||
}
|
||||
|
||||
func Load() EnvConfig {
|
||||
@@ -38,11 +39,14 @@ func Load() EnvConfig {
|
||||
dashboardHost = "localhost"
|
||||
}
|
||||
|
||||
staticDashboardPath := os.Getenv("STATIC_DASHBOARD_PATH")
|
||||
|
||||
return EnvConfig{
|
||||
Port: port,
|
||||
ConfigDir: configDir,
|
||||
GithubPat: githubPat,
|
||||
StoragePath: storagePath,
|
||||
DashboardHost: dashboardHost,
|
||||
Port: port,
|
||||
ConfigDir: configDir,
|
||||
GithubPat: githubPat,
|
||||
StoragePath: storagePath,
|
||||
DashboardHost: dashboardHost,
|
||||
StaticDashboardPath: staticDashboardPath,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,11 @@
|
||||
package fiberconfig
|
||||
|
||||
import (
|
||||
"github.com/Flussen/swagger-fiber-v3"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
"github.com/gofiber/fiber/v3/middleware/logger"
|
||||
"github.com/gofiber/fiber/v3/middleware/static"
|
||||
)
|
||||
|
||||
func Setup(app *fiber.App) {
|
||||
app.Get("/api/docs.json", static.New("./docs/swagger.json"))
|
||||
|
||||
app.Get("/api/swagger/*", swagger.New(swagger.Config{
|
||||
URL: "/api/docs.json",
|
||||
Title: "mcheads.net API Documentation",
|
||||
}))
|
||||
|
||||
app.Use("/api", func(c fiber.Ctx) error {
|
||||
c.Set("Content-Type", "application/json")
|
||||
return c.Next()
|
||||
})
|
||||
|
||||
app.Use(logger.New(logger.Config{
|
||||
Format: "[${time}] ${status} - ${method} ${path} (${latency}) - ${ip}\n",
|
||||
TimeFormat: "2006-01-02 15:04:05",
|
||||
|
||||
Reference in New Issue
Block a user