some cleanup

This commit is contained in:
2026-10-07 15:35:04 +02:00
parent c7e7e615c2
commit 8e3abca9d7
13 changed files with 179 additions and 121 deletions
+15 -1
View File
@@ -3,8 +3,11 @@ package config
import (
"github.com/adrg/xdg"
"github.com/pelletier/go-toml"
"net"
"net/url"
"os"
"path/filepath"
"strconv"
)
var confPath string
@@ -18,7 +21,7 @@ func init() {
Server: Server{
Host: "127.0.0.1",
Port: 8080,
FrontendUrls: []string{"http://localhost:5173"},
FrontendUrls: []string{"http://localhost:5173", "http://127.0.0.1:5173"},
},
Database: Database{
User: "pp",
@@ -75,6 +78,17 @@ type Database struct {
Name string
}
// URL returns the Postgres connection URL. The local dev database has no SSL.
func (d Database) URL() *url.URL {
return &url.URL{
Scheme: "postgres",
User: url.UserPassword(d.User, d.Password),
Host: net.JoinHostPort(d.Host, strconv.Itoa(d.Port)),
Path: "/" + d.Name,
RawQuery: "sslmode=disable",
}
}
type Config struct {
Server Server
Database Database