Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
ff81ea60
Commit
ff81ea60
authored
Apr 07, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: tweak error message
parent
8101a5e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
23 deletions
+23
-23
main.go
bin/memos/main.go
+18
-18
auth_service.go
server/route/api/v2/auth_service.go
+1
-1
memo_service.go
server/route/api/v2/memo_service.go
+4
-4
No files found.
bin/memos/main.go
View file @
ff81ea60
...
...
@@ -14,7 +14,7 @@ import (
"github.com/usememos/memos/internal/jobs"
"github.com/usememos/memos/server"
_profile
"github.com/usememos/memos/server/profile"
"github.com/usememos/memos/server/profile"
"github.com/usememos/memos/store"
"github.com/usememos/memos/store/db"
)
...
...
@@ -31,22 +31,22 @@ const (
)
var
(
profile
*
_profile
.
Profile
mode
string
addr
string
port
int
d
ata
string
d
river
string
dsn
string
serveFrontend
bool
allowedOrigins
[]
string
mode
string
addr
string
port
int
data
string
d
river
string
d
sn
string
serveFrontend
bool
allowedOrigins
[]
string
instanceProfile
*
profile
.
Profile
rootCmd
=
&
cobra
.
Command
{
Use
:
"memos"
,
Short
:
`An open source, lightweight note-taking service. Easily capture and share your great thoughts.`
,
Run
:
func
(
_cmd
*
cobra
.
Command
,
_args
[]
string
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
dbDriver
,
err
:=
db
.
NewDBDriver
(
p
rofile
)
dbDriver
,
err
:=
db
.
NewDBDriver
(
instanceP
rofile
)
if
err
!=
nil
{
cancel
()
slog
.
Error
(
"failed to create db driver"
,
err
)
...
...
@@ -58,14 +58,14 @@ var (
return
}
storeInstance
:=
store
.
New
(
dbDriver
,
p
rofile
)
storeInstance
:=
store
.
New
(
dbDriver
,
instanceP
rofile
)
if
err
:=
storeInstance
.
MigrateManually
(
ctx
);
err
!=
nil
{
cancel
()
slog
.
Error
(
"failed to migrate manually"
,
err
)
return
}
s
,
err
:=
server
.
NewServer
(
ctx
,
p
rofile
,
storeInstance
)
s
,
err
:=
server
.
NewServer
(
ctx
,
instanceP
rofile
,
storeInstance
)
if
err
!=
nil
{
cancel
()
slog
.
Error
(
"failed to create server"
,
err
)
...
...
@@ -162,7 +162,7 @@ func init() {
func
initConfig
()
{
viper
.
AutomaticEnv
()
var
err
error
profile
,
err
=
_
profile
.
GetProfile
()
instanceProfile
,
err
=
profile
.
GetProfile
()
if
err
!=
nil
{
fmt
.
Printf
(
"failed to get profile, error: %+v
\n
"
,
err
)
return
...
...
@@ -179,15 +179,15 @@ mode: %s
driver: %s
frontend: %t
---
`
,
profile
.
Version
,
profile
.
Data
,
profile
.
DSN
,
profile
.
Addr
,
profile
.
Port
,
profile
.
Mode
,
profile
.
Driver
,
p
rofile
.
Frontend
)
`
,
instanceProfile
.
Version
,
instanceProfile
.
Data
,
instanceProfile
.
DSN
,
instanceProfile
.
Addr
,
instanceProfile
.
Port
,
instanceProfile
.
Mode
,
instanceProfile
.
Driver
,
instanceP
rofile
.
Frontend
)
}
func
printGreetings
()
{
print
(
greetingBanner
)
if
len
(
p
rofile
.
Addr
)
==
0
{
fmt
.
Printf
(
"Version %s has been started on port %d
\n
"
,
profile
.
Version
,
p
rofile
.
Port
)
if
len
(
instanceP
rofile
.
Addr
)
==
0
{
fmt
.
Printf
(
"Version %s has been started on port %d
\n
"
,
instanceProfile
.
Version
,
instanceP
rofile
.
Port
)
}
else
{
fmt
.
Printf
(
"Version %s has been started on address '%s' and port %d
\n
"
,
profile
.
Version
,
profile
.
Addr
,
p
rofile
.
Port
)
fmt
.
Printf
(
"Version %s has been started on address '%s' and port %d
\n
"
,
instanceProfile
.
Version
,
instanceProfile
.
Addr
,
instanceP
rofile
.
Port
)
}
fmt
.
Printf
(
`---
See more in:
...
...
server/route/api/v2/auth_service.go
View file @
ff81ea60
...
...
@@ -30,7 +30,7 @@ func (s *APIV2Service) GetAuthStatus(ctx context.Context, _ *apiv2pb.GetAuthStat
if
user
==
nil
{
// Set the cookie header to expire access token.
if
err
:=
s
.
clearAccessTokenCookie
(
ctx
);
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to set grpc header
"
)
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to set grpc header
: %v"
,
err
)
}
return
nil
,
status
.
Errorf
(
codes
.
Unauthenticated
,
"user not found"
)
}
...
...
server/route/api/v2/memo_service.go
View file @
ff81ea60
...
...
@@ -106,7 +106,7 @@ func (s *APIV2Service) ListMemos(ctx context.Context, request *apiv2pb.ListMemos
memoFind
.
Offset
=
&
offset
memos
,
err
:=
s
.
Store
.
ListMemos
(
ctx
,
memoFind
)
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to list memos
"
)
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to list memos
: %v"
,
err
)
}
memoMessages
:=
[]
*
apiv2pb
.
Memo
{}
...
...
@@ -459,7 +459,7 @@ func (s *APIV2Service) GetUserMemosStats(ctx context.Context, request *apiv2pb.G
memos
,
err
:=
s
.
Store
.
ListMemos
(
ctx
,
memoFind
)
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to list memos
"
)
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to list memos
: %v"
,
err
)
}
location
,
err
:=
time
.
LoadLocation
(
request
.
Timezone
)
...
...
@@ -494,12 +494,12 @@ func (s *APIV2Service) ExportMemos(ctx context.Context, request *apiv2pb.ExportM
ExcludeComments
:
true
,
}
if
err
:=
s
.
buildMemoFindWithFilter
(
ctx
,
memoFind
,
request
.
Filter
);
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to build find memos with filter
"
)
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to build find memos with filter
: %v"
,
err
)
}
memos
,
err
:=
s
.
Store
.
ListMemos
(
ctx
,
memoFind
)
if
err
!=
nil
{
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to list memos
"
)
return
nil
,
status
.
Errorf
(
codes
.
Internal
,
"failed to list memos
: %v"
,
err
)
}
buf
:=
new
(
bytes
.
Buffer
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment