From c7af8d6afa2c7809b60b12578a0d5c05f9aa3c95 Mon Sep 17 00:00:00 2001
From: Steven <stevenlgtm@gmail.com>
Date: Tue, 26 Mar 2024 20:35:36 +0800
Subject: [PATCH] chore: move frontend package

---
 server/route/api/v1/collection_service.go                | 1 -
 server/{embed_frontend.go => route/frontend/frontend.go} | 5 ++++-
 server/server.go                                         | 3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)
 rename server/{embed_frontend.go => route/frontend/frontend.go} (97%)

diff --git a/server/route/api/v1/collection_service.go b/server/route/api/v1/collection_service.go
index dc34506..1e3d2bf 100644
--- a/server/route/api/v1/collection_service.go
+++ b/server/route/api/v1/collection_service.go
@@ -100,7 +100,6 @@ func (s *APIV2Service) GetCollectionByName(ctx context.Context, request *apiv1pb
 	response := &apiv1pb.GetCollectionByNameResponse{
 		Collection: convertCollectionFromStore(collection),
 	}
-	metric.Enqueue("collection view")
 	return response, nil
 }
 
diff --git a/server/embed_frontend.go b/server/route/frontend/frontend.go
similarity index 97%
rename from server/embed_frontend.go
rename to server/route/frontend/frontend.go
index c318cec..6ad2c57 100644
--- a/server/embed_frontend.go
+++ b/server/route/frontend/frontend.go
@@ -1,4 +1,4 @@
-package server
+package frontend
 
 import (
 	"context"
@@ -12,6 +12,7 @@ import (
 
 	"github.com/yourselfhosted/slash/internal/util"
 	storepb "github.com/yourselfhosted/slash/proto/gen/store"
+	"github.com/yourselfhosted/slash/server/metric"
 	"github.com/yourselfhosted/slash/server/profile"
 	"github.com/yourselfhosted/slash/store"
 )
@@ -63,6 +64,7 @@ func (s *FrontendService) registerRoutes(e *echo.Echo) {
 			return c.HTML(http.StatusOK, rawIndexHTML)
 		}
 
+		metric.Enqueue("shortcut view")
 		// Inject shortcut metadata into `index.html`.
 		indexHTML := strings.ReplaceAll(rawIndexHTML, headerMetadataPlaceholder, generateShortcutMetadata(shortcut).String())
 		return c.HTML(http.StatusOK, indexHTML)
@@ -81,6 +83,7 @@ func (s *FrontendService) registerRoutes(e *echo.Echo) {
 			return c.HTML(http.StatusOK, rawIndexHTML)
 		}
 
+		metric.Enqueue("collection view")
 		// Inject collection metadata into `index.html`.
 		indexHTML := strings.ReplaceAll(rawIndexHTML, headerMetadataPlaceholder, generateCollectionMetadata(collection).String())
 		return c.HTML(http.StatusOK, indexHTML)
diff --git a/server/server.go b/server/server.go
index 4153756..1f72eaf 100644
--- a/server/server.go
+++ b/server/server.go
@@ -16,6 +16,7 @@ import (
 	"github.com/yourselfhosted/slash/server/metric"
 	"github.com/yourselfhosted/slash/server/profile"
 	apiv1 "github.com/yourselfhosted/slash/server/route/api/v1"
+	"github.com/yourselfhosted/slash/server/route/frontend"
 	"github.com/yourselfhosted/slash/server/service/license"
 	"github.com/yourselfhosted/slash/server/service/resource"
 	"github.com/yourselfhosted/slash/store"
@@ -50,7 +51,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
 	}
 
 	// Serve frontend.
-	frontendService := NewFrontendService(profile, store)
+	frontendService := frontend.NewFrontendService(profile, store)
 	frontendService.Serve(ctx, e)
 
 	// In dev mode, we'd like to set the const secret key to make signin session persistence.