Skip to content

armgit / memos

Public Imported from GitHub
0

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.

chore: remove unused flags

Steven10c57167cc9d
diff --git a/bin/memos/main.go b/bin/memos/main.go
index b2c4eed05..0496cba1d 100644
--- a/bin/memos/main.go
+++ b/bin/memos/main.go
@@ -36,8 +36,6 @@ var (
data string
driver string
dsn string
- serveFrontend bool
- allowedOrigins []string
instanceProfile *profile.Profile
rootCmd = &cobra.Command{
@@ -111,8 +109,6 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&data, "data", "d", "", "data directory")
rootCmd.PersistentFlags().StringVarP(&driver, "driver", "", "", "database driver")
rootCmd.PersistentFlags().StringVarP(&dsn, "dsn", "", "", "database source name(aka. DSN)")
- rootCmd.PersistentFlags().BoolVarP(&serveFrontend, "frontend", "", true, "serve frontend files")
- rootCmd.PersistentFlags().StringArrayVarP(&allowedOrigins, "origins", "", []string{}, "CORS allowed domain origins")
err := viper.BindPFlag("mode", rootCmd.PersistentFlags().Lookup("mode"))
if err != nil {
@@ -138,21 +134,11 @@ func init() {
if err != nil {
panic(err)
}
- err = viper.BindPFlag("frontend", rootCmd.PersistentFlags().Lookup("frontend"))
- if err != nil {
- panic(err)
- }
- err = viper.BindPFlag("origins", rootCmd.PersistentFlags().Lookup("origins"))
- if err != nil {
- panic(err)
- }
viper.SetDefault("mode", "demo")
viper.SetDefault("driver", "sqlite")
viper.SetDefault("addr", "")
viper.SetDefault("port", 8081)
- viper.SetDefault("frontend", true)
- viper.SetDefault("origins", []string{})
viper.SetEnvPrefix("memos")
}
@@ -174,9 +160,8 @@ addr: %s
port: %d
mode: %s
driver: %s
-frontend: %t
---
-`, instanceProfile.Version, instanceProfile.Data, instanceProfile.DSN, instanceProfile.Addr, instanceProfile.Port, instanceProfile.Mode, instanceProfile.Driver, instanceProfile.Frontend)
+`, instanceProfile.Version, instanceProfile.Data, instanceProfile.DSN, instanceProfile.Addr, instanceProfile.Port, instanceProfile.Mode, instanceProfile.Driver)
}
func printGreetings() {
diff --git a/server/profile/profile.go b/server/profile/profile.go
index d9d15c27f..020dca782 100644
--- a/server/profile/profile.go
+++ b/server/profile/profile.go
@@ -30,10 +30,6 @@ type Profile struct {
Driver string `json:"-"`
// Version is the current version of server
Version string `json:"version"`
- // Frontend indicate the frontend is enabled or not
- Frontend bool `json:"-"`
- // Origins is the list of allowed origins
- Origins []string `json:"-"`
}
func (p *Profile) IsDev() bool {
diff --git a/server/server.go b/server/server.go
index cee176841..27d0165ee 100644
--- a/server/server.go
+++ b/server/server.go
@@ -61,11 +61,8 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
return c.String(http.StatusOK, "Service ready.")
})
- // Only serve frontend when it's enabled.
- if profile.Frontend {
- frontendService := frontend.NewFrontendService(profile, store)
- frontendService.Serve(ctx, echoServer)
- }
+ // Serve frontend resources.
+ frontend.NewFrontendService(profile, store).Serve(ctx, echoServer)
rootGroup := echoServer.Group("")
diff --git a/web/.env.example b/web/.env.example
deleted file mode 100644
index 0f4e8826d..000000000
--- a/web/.env.example
+++ /dev/null
@@ -1 +0,0 @@
-VITE_API_BASE_URL=http://localhost:8081
diff --git a/web/src/grpcweb.ts b/web/src/grpcweb.ts
index 2d3ba8bc6..0d20a0ad4 100644
--- a/web/src/grpcweb.ts
+++ b/web/src/grpcweb.ts
@@ -13,7 +13,7 @@ import { WorkspaceServiceDefinition } from "./types/proto/api/v1/workspace_servi
import { WorkspaceSettingServiceDefinition } from "./types/proto/api/v1/workspace_setting_service";
const channel = createChannel(
- import.meta.env.VITE_API_BASE_URL || window.location.origin,
+ window.location.origin,
FetchTransport({
credentials: "include",
}),
diff --git a/web/src/utils/resource.ts b/web/src/utils/resource.ts
index 6f38f7e3f..d8627d1c5 100644
--- a/web/src/utils/resource.ts
+++ b/web/src/utils/resource.ts
@@ -5,7 +5,7 @@ export const getResourceUrl = (resource: Resource) => {
return resource.externalLink;
}
- return `${import.meta.env.VITE_API_BASE_URL || window.location.origin}/file/${resource.name}`;
+ return `${window.location.origin}/file/${resource.name}`;
};
export const getResourceType = (resource: Resource) => {