36 lines
658 B
Go
36 lines
658 B
Go
package main
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
|
|
"git.wittern.io/public/echo-todos/handler"
|
|
"git.wittern.io/public/echo-todos/pkg/db"
|
|
"git.wittern.io/public/echo-todos/view"
|
|
|
|
"github.com/joho/godotenv"
|
|
"github.com/labstack/echo/v4"
|
|
_ "github.com/mattn/go-sqlite3"
|
|
)
|
|
|
|
var Username = "My"
|
|
|
|
func main() {
|
|
WEBURL := "0.0.0.0:1337"
|
|
e := echo.New()
|
|
err := godotenv.Load()
|
|
Username = os.Getenv("USERNAME")
|
|
|
|
view.Username = Username
|
|
database, err := db.InitDB()
|
|
if err != nil {
|
|
slog.Error("failed to open database", "Error", err)
|
|
|
|
}
|
|
defer database.Close()
|
|
|
|
dbhandler := handler.DBHandler{DB: database}
|
|
|
|
handler.AddRoutes(dbhandler, e)
|
|
e.Start(WEBURL)
|
|
}
|