chore: init Vue

This commit is contained in:
DaanSelen
2026-04-21 08:42:21 +02:00
parent 4b783b50fb
commit 610fdffdb8
20 changed files with 1645 additions and 60 deletions
+9 -4
View File
@@ -10,12 +10,17 @@ import (
)
func KickoffApi(env runtime.Environment, db *gorm.DB) {
router := gin.Default()
router.LoadHTMLFiles("./web/templates/index.html")
r := gin.Default()
spawnRoutes(router, env, db)
api := r.Group("/api")
spawnRoutes(api, env, db)
err := router.Run(fmt.Sprintf("%s:%s", env.Hostname, env.Port))
r.Static("/assets", "./web/frontend/dist/assets")
r.NoRoute(func(c *gin.Context) {
c.File("./web/frontend/dist/index.html")
})
err := r.Run(fmt.Sprintf("%s:%s", env.Hostname, env.Port))
if err != nil {
slog.Error("failed to start the Gin server due to: " + err.Error())
}
+5 -5
View File
@@ -27,10 +27,10 @@ func categorizeFile(ext string) string {
}
}
func spawnRoutes(r *gin.Engine, env runtime.Environment, db *gorm.DB) {
func spawnRoutes(api *gin.RouterGroup, env runtime.Environment, db *gorm.DB) {
// The Root endpoint '/' displays a simple HTML template.
// from root: ./templates/index.html
r.GET("/", func(c *gin.Context) {
api.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html",
gin.H{
"title": env.Codename,
@@ -41,7 +41,7 @@ func spawnRoutes(r *gin.Engine, env runtime.Environment, db *gorm.DB) {
// prefix: api
// Display the information on what is going on at the moment
r.GET("/api/status", func(c *gin.Context) {
api.GET("/api/status", func(c *gin.Context) {
state, err := database.GetAppState(db)
if err != nil {
slog.Warn("unable to determine state")
@@ -51,7 +51,7 @@ func spawnRoutes(r *gin.Engine, env runtime.Environment, db *gorm.DB) {
})
// define the upload route
r.POST("/api/upload", func(c *gin.Context) {
api.POST("/api/upload", func(c *gin.Context) {
file, err := c.FormFile("file")
if err != nil {
slog.Error("missing file upload", "error", err)
@@ -74,7 +74,7 @@ func spawnRoutes(r *gin.Engine, env runtime.Environment, db *gorm.DB) {
})
// define a route to check what is registered
r.GET("/api/available", func(c *gin.Context) {
api.GET("/api/available", func(c *gin.Context) {
files, err := database.GetFiles(db)
if err != nil {
slog.Error("failed to retrieve available files", "error", err)
+1
View File
@@ -38,6 +38,7 @@ func EnsureOperation(workDir string) error {
workDir,
filepath.Join(workDir, "content"),
filepath.Join(workDir, "content", "fresh"),
filepath.Join(workDir, "content", "archive"),
filepath.Join(workDir, "web"),
}