Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: update frontend service
Steven68413a5371c7
diff --git a/go.mod b/go.modindex 53341bfc3..ac3df7172 100644--- a/go.mod+++ b/go.mod@@ -23,7 +23,6 @@ require (github.com/spf13/cobra v1.8.0github.com/spf13/viper v1.17.0github.com/stretchr/testify v1.8.4- github.com/swaggo/echo-swagger v1.4.1github.com/swaggo/swag v1.16.2go.uber.org/zap v1.26.0golang.org/x/crypto v0.17.0@@ -43,7 +42,6 @@ require (github.com/cenkalti/backoff/v4 v4.2.1 // indirectgithub.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirectgithub.com/dustin/go-humanize v1.0.1 // indirect- github.com/ghodss/yaml v1.0.0 // indirectgithub.com/go-openapi/jsonpointer v0.20.0 // indirectgithub.com/go-openapi/jsonreference v0.20.2 // indirectgithub.com/go-openapi/spec v0.20.9 // indirect@@ -60,12 +58,10 @@ require (github.com/sagikazarmark/slog-shim v0.1.0 // indirectgithub.com/sourcegraph/conc v0.3.0 // indirectgithub.com/stoewer/go-strcase v1.3.0 // indirect- github.com/swaggo/files/v2 v2.0.0 // indirectgolang.org/x/image v0.13.0 // indirectgolang.org/x/tools v0.14.0 // indirectgoogle.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirectgoogle.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect- gopkg.in/yaml.v2 v2.4.0 // indirectlukechampine.com/uint128 v1.3.0 // indirectmodernc.org/cc/v3 v3.41.0 // indirectmodernc.org/ccgo/v3 v3.16.15 // indirectdiff --git a/go.sum b/go.sumindex 222d458c0..5ffe9cfb7 100644--- a/go.sum+++ b/go.sum@@ -162,7 +162,6 @@ github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zgithub.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=-github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=@@ -549,10 +548,6 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUgithub.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=-github.com/swaggo/echo-swagger v1.4.1 h1:Yf0uPaJWp1uRtDloZALyLnvdBeoEL5Kc7DtnjzO/TUk=-github.com/swaggo/echo-swagger v1.4.1/go.mod h1:C8bSi+9yH2FLZsnhqMZLIZddpUxZdBYuNHbtaS1Hljc=-github.com/swaggo/files/v2 v2.0.0 h1:hmAt8Dkynw7Ssz46F6pn8ok6YmGZqHSVLZ+HQM7i0kw=-github.com/swaggo/files/v2 v2.0.0/go.mod h1:24kk2Y9NYEJ5lHuCra6iVwkMjIekMCaFq/0JQj66kyM=github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04=github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E=github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=diff --git a/server/frontend/frontend.go b/server/frontend/frontend.goindex 7202b55e6..561d7f972 100644--- a/server/frontend/frontend.go+++ b/server/frontend/frontend.go@@ -35,17 +35,18 @@ func (s *FrontendService) Serve(e *echo.Echo) {// Use echo static middleware to serve the built dist folder.// refer: https://github.com/labstack/echo/blob/master/middleware/static.goe.Use(middleware.StaticWithConfig(middleware.StaticConfig{- Root: "dist",- Skipper: defaultAPIRequestSkipper,- HTML5: true,+ HTML5: true,+ Filesystem: http.Dir("dist"),+ Skipper: func(c echo.Context) bool {+ return util.HasPrefixes(c.Path(), "/api", "/memos.api.v2", "/robots.txt", "/sitemap.xml", "/m/:memoID")+ },}))s.registerRoutes(e)}func (s *FrontendService) registerRoutes(e *echo.Echo) {- rawIndexHTMLBytes, _ := os.ReadFile("dist/index.html")- rawIndexHTML := string(rawIndexHTMLBytes)+ rawIndexHTML := getRawIndexHTML()e.GET("/robots.txt", func(c echo.Context) error {ctx := c.Request().Context()@@ -173,7 +174,7 @@ func generateMemoMetadata(memo *store.Memo, creator *store.User) string {return strings.Join(metadataList, "\n")}-func defaultAPIRequestSkipper(c echo.Context) bool {- path := c.Request().URL.Path- return util.HasPrefixes(path, "/api", "/memos.api.v2")+func getRawIndexHTML() string {+ bytes, _ := os.ReadFile("dist/index.html")+ return string(bytes)}diff --git a/server/server.go b/server/server.goindex 60c8e964d..9aabb27e4 100644--- a/server/server.go+++ b/server/server.go@@ -11,7 +11,6 @@ import ("github.com/labstack/echo/v4""github.com/labstack/echo/v4/middleware""github.com/pkg/errors"- echoSwagger "github.com/swaggo/echo-swagger"apiv1 "github.com/usememos/memos/api/v1"apiv2 "github.com/usememos/memos/api/v2"@@ -74,15 +73,10 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store}s.ID = serverID- // Serve frontend.+ // Register frontend service.frontendService := frontend.NewFrontendService(profile, store)frontendService.Serve(e)- // Serve swagger in dev/demo mode.- if profile.Mode == "dev" || profile.Mode == "demo" {- e.GET("/api/*", echoSwagger.WrapHandler)- }-secret := "usememos"if profile.Mode == "prod" {secret, err = s.getSystemSecretSessionName(ctx)