Documentation ¶
Index ¶
- Constants
- Variables
- func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) echo.HandlerFunc
- type APIV1Service
- type Activity
- type ActivityCreate
- type ActivityLevel
- type ActivityMemoCreatePayload
- type ActivityResourceCreatePayload
- type ActivityServerStartPayload
- type ActivityShortcutCreatePayload
- type ActivityTagCreatePayload
- type ActivityType
- type ActivityUserAuthSignInPayload
- type ActivityUserAuthSignUpPayload
- type ActivityUserCreatePayload
- type Claims
- type CreateIdentityProviderRequest
- type CustomizedProfile
- type FieldMapping
- type IdentityProvider
- type IdentityProviderConfig
- type IdentityProviderOAuth2Config
- type IdentityProviderType
- type OpenAIConfig
- type Role
- type RowStatus
- type SSOSignIn
- type SignIn
- type SignUp
- type SystemSetting
- type SystemSettingFind
- type SystemSettingName
- type SystemSettingUpsert
- type UpdateIdentityProviderRequest
- type UserSetting
- type UserSettingDelete
- type UserSettingFind
- type UserSettingKey
- type UserSettingUpsert
- type Visibility
Constants ¶
const UnknownID = -1
UnknownID is the ID for unknowns.
Variables ¶
var ( UserSettingLocaleValue = []string{ "de", "en", "es", "fr", "hr", "it", "ja", "ko", "nl", "pl", "pt-BR", "ru", "sl", "sv", "tr", "uk", "vi", "zh-Hans", "zh-Hant", } UserSettingAppearanceValue = []string{"system", "light", "dark"} UserSettingMemoVisibilityValue = []Visibility{Private, Protected, Public} )
Functions ¶
func JWTMiddleware ¶
func JWTMiddleware(server *APIV1Service, next echo.HandlerFunc, secret string) echo.HandlerFunc
JWTMiddleware validates the access token. If the access token is about to expire or has expired and the request has a valid refresh token, it will try to generate new access token and refresh token.
Types ¶
type APIV1Service ¶
func NewAPIV1Service ¶
func (*APIV1Service) Register ¶
func (s *APIV1Service) Register(rootGroup *echo.Group)
type Activity ¶
type Activity struct { ID int `json:"id"` // Standard fields CreatorID int `json:"creatorId"` CreatedTs int64 `json:"createdTs"` // Domain specific fields Type ActivityType `json:"type"` Level ActivityLevel `json:"level"` Payload string `json:"payload"` }
type ActivityCreate ¶
type ActivityCreate struct { // Standard fields CreatorID int // Domain specific fields Type ActivityType `json:"type"` Level ActivityLevel Payload string `json:"payload"` }
ActivityCreate is the API message for creating an activity.
type ActivityLevel ¶
type ActivityLevel string
ActivityLevel is the level of activities.
const ( // ActivityInfo is the INFO level of activities. ActivityInfo ActivityLevel = "INFO" // ActivityWarn is the WARN level of activities. ActivityWarn ActivityLevel = "WARN" // ActivityError is the ERROR level of activities. ActivityError ActivityLevel = "ERROR" )
type ActivityTagCreatePayload ¶
type ActivityTagCreatePayload struct {
TagName string `json:"tagName"`
}
type ActivityType ¶
type ActivityType string
ActivityType is the type for an activity.
const ( // ActivityUserCreate is the type for creating users. ActivityUserCreate ActivityType = "user.create" // ActivityUserUpdate is the type for updating users. ActivityUserUpdate ActivityType = "user.update" // ActivityUserDelete is the type for deleting users. ActivityUserDelete ActivityType = "user.delete" // ActivityUserAuthSignIn is the type for user signin. ActivityUserAuthSignIn ActivityType = "user.auth.signin" // ActivityUserAuthSignUp is the type for user signup. ActivityUserAuthSignUp ActivityType = "user.auth.signup" // ActivityUserSettingUpdate is the type for updating user settings. ActivityUserSettingUpdate ActivityType = "user.setting.update" // ActivityMemoCreate is the type for creating memos. ActivityMemoCreate ActivityType = "memo.create" // ActivityMemoUpdate is the type for updating memos. ActivityMemoUpdate ActivityType = "memo.update" // ActivityMemoDelete is the type for deleting memos. ActivityMemoDelete ActivityType = "memo.delete" // ActivityShortcutCreate is the type for creating shortcuts. ActivityShortcutCreate ActivityType = "shortcut.create" // ActivityShortcutUpdate is the type for updating shortcuts. ActivityShortcutUpdate ActivityType = "shortcut.update" // ActivityShortcutDelete is the type for deleting shortcuts. ActivityShortcutDelete ActivityType = "shortcut.delete" // ActivityResourceCreate is the type for creating resources. ActivityResourceCreate ActivityType = "resource.create" // ActivityResourceDelete is the type for deleting resources. ActivityResourceDelete ActivityType = "resource.delete" // ActivityTagCreate is the type for creating tags. ActivityTagCreate ActivityType = "tag.create" // ActivityTagDelete is the type for deleting tags. ActivityTagDelete ActivityType = "tag.delete" // ActivityServerStart is the type for starting server. ActivityServerStart ActivityType = "server.start" )
type Claims ¶
type Claims struct { Name string `json:"name"` jwt.RegisteredClaims }
Claims creates a struct that will be encoded to a JWT. We add jwt.RegisteredClaims as an embedded type, to provide fields such as name.
type CreateIdentityProviderRequest ¶
type CreateIdentityProviderRequest struct { Name string `json:"name"` Type IdentityProviderType `json:"type"` IdentifierFilter string `json:"identifierFilter"` Config *IdentityProviderConfig `json:"config"` }
type CustomizedProfile ¶
type CustomizedProfile struct { // Name is the server name, default is `memos` Name string `json:"name"` // LogoURL is the url of logo image. LogoURL string `json:"logoUrl"` // Description is the server description. Description string `json:"description"` // Locale is the server default locale. Locale string `json:"locale"` // Appearance is the server default appearance. Appearance string `json:"appearance"` // ExternalURL is the external url of server. e.g. https://usermemos.com ExternalURL string `json:"externalUrl"` }
CustomizedProfile is the struct definition for SystemSettingCustomizedProfileName system setting item.
type FieldMapping ¶
type IdentityProvider ¶
type IdentityProvider struct { ID int `json:"id"` Name string `json:"name"` Type IdentityProviderType `json:"type"` IdentifierFilter string `json:"identifierFilter"` Config *IdentityProviderConfig `json:"config"` }
type IdentityProviderConfig ¶
type IdentityProviderConfig struct {
OAuth2Config *IdentityProviderOAuth2Config `json:"oauth2Config"`
}
type IdentityProviderOAuth2Config ¶
type IdentityProviderOAuth2Config struct { ClientID string `json:"clientId"` ClientSecret string `json:"clientSecret"` AuthURL string `json:"authUrl"` TokenURL string `json:"tokenUrl"` UserInfoURL string `json:"userInfoUrl"` Scopes []string `json:"scopes"` FieldMapping *FieldMapping `json:"fieldMapping"` }
type IdentityProviderType ¶
type IdentityProviderType string
const (
IdentityProviderOAuth2 IdentityProviderType = "OAUTH2"
)
type OpenAIConfig ¶
type SystemSetting ¶
type SystemSetting struct { Name SystemSettingName `json:"name"` // Value is a JSON string with basic value. Value string `json:"value"` Description string `json:"description"` }
type SystemSettingFind ¶
type SystemSettingFind struct {
Name SystemSettingName `json:"name"`
}
type SystemSettingName ¶
type SystemSettingName string
const ( // SystemSettingServerIDName is the name of server id. SystemSettingServerIDName SystemSettingName = "server-id" // SystemSettingSecretSessionName is the name of secret session. SystemSettingSecretSessionName SystemSettingName = "secret-session" // SystemSettingAllowSignUpName is the name of allow signup setting. SystemSettingAllowSignUpName SystemSettingName = "allow-signup" // SystemSettingDisablePublicMemosName is the name of disable public memos setting. SystemSettingDisablePublicMemosName SystemSettingName = "disable-public-memos" // SystemSettingMaxUploadSizeMiBName is the name of max upload size setting. SystemSettingMaxUploadSizeMiBName SystemSettingName = "max-upload-size-mib" // SystemSettingAdditionalStyleName is the name of additional style. SystemSettingAdditionalStyleName SystemSettingName = "additional-style" // SystemSettingAdditionalScriptName is the name of additional script. SystemSettingAdditionalScriptName SystemSettingName = "additional-script" // SystemSettingCustomizedProfileName is the name of customized server profile. SystemSettingCustomizedProfileName SystemSettingName = "customized-profile" // SystemSettingStorageServiceIDName is the name of storage service ID. SystemSettingStorageServiceIDName SystemSettingName = "storage-service-id" // SystemSettingLocalStoragePathName is the name of local storage path. SystemSettingLocalStoragePathName SystemSettingName = "local-storage-path" // SystemSettingOpenAIConfigName is the name of OpenAI config. SystemSettingOpenAIConfigName SystemSettingName = "openai-config" // SystemSettingTelegramBotToken is the name of Telegram Bot Token. SystemSettingTelegramBotTokenName SystemSettingName = "telegram-bot-token" SystemSettingMemoDisplayWithUpdatedTsName SystemSettingName = "memo-display-with-updated-ts" )
func (SystemSettingName) String ¶
func (key SystemSettingName) String() string
type SystemSettingUpsert ¶
type SystemSettingUpsert struct { Name SystemSettingName `json:"name"` Value string `json:"value"` Description string `json:"description"` }
func (SystemSettingUpsert) Validate ¶
func (upsert SystemSettingUpsert) Validate() error
type UpdateIdentityProviderRequest ¶
type UpdateIdentityProviderRequest struct { ID int Type IdentityProviderType `json:"type"` Name *string `json:"name"` IdentifierFilter *string `json:"identifierFilter"` Config *IdentityProviderConfig `json:"config"` }
type UserSetting ¶
type UserSetting struct { UserID int Key UserSettingKey `json:"key"` // Value is a JSON string with basic value Value string `json:"value"` }
type UserSettingDelete ¶
type UserSettingDelete struct {
UserID int
}
type UserSettingFind ¶
type UserSettingFind struct { UserID *int Key UserSettingKey `json:"key"` }
type UserSettingKey ¶
type UserSettingKey string
const ( // UserSettingLocaleKey is the key type for user locale. UserSettingLocaleKey UserSettingKey = "locale" // UserSettingAppearanceKey is the key type for user appearance. UserSettingAppearanceKey UserSettingKey = "appearance" // UserSettingMemoVisibilityKey is the key type for user preference memo default visibility. UserSettingMemoVisibilityKey UserSettingKey = "memo-visibility" // UserSettingTelegramUserID is the key type for telegram UserID of memos user. UserSettingTelegramUserIDKey UserSettingKey = "telegram-user-id" )
func (UserSettingKey) String ¶
func (key UserSettingKey) String() string
String returns the string format of UserSettingKey type.
type UserSettingUpsert ¶
type UserSettingUpsert struct { UserID int `json:"-"` Key UserSettingKey `json:"key"` Value string `json:"value"` }
func (UserSettingUpsert) Validate ¶
func (upsert UserSettingUpsert) Validate() error
type Visibility ¶
type Visibility string
Visibility is the type of a visibility.
const ( // Public is the PUBLIC visibility. Public Visibility = "PUBLIC" // Protected is the PROTECTED visibility. Protected Visibility = "PROTECTED" // Private is the PRIVATE visibility. Private Visibility = "PRIVATE" )
func (Visibility) String ¶
func (v Visibility) String() string