chore: move frontend package

This commit is contained in:
Steven 2024-03-26 20:35:36 +08:00
parent 1025d8a2ed
commit c7af8d6afa
3 changed files with 6 additions and 3 deletions

View File

@ -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
}

View File

@ -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)

View File

@ -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.