mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: update api v1 docs (#2117)
* chore: update apiv1 docs * chore: update
This commit is contained in:
@@ -32,13 +32,13 @@ type SignUp struct {
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerAuthRoutes(g *echo.Group) {
|
||||
g.POST("/auth/signin", s.signIn)
|
||||
g.POST("/auth/signin/sso", s.signInSSO)
|
||||
g.POST("/auth/signout", s.signOut)
|
||||
g.POST("/auth/signup", s.signUp)
|
||||
g.POST("/auth/signin", s.SignIn)
|
||||
g.POST("/auth/signin/sso", s.SignInSSO)
|
||||
g.POST("/auth/signout", s.SignOut)
|
||||
g.POST("/auth/signup", s.SignUp)
|
||||
}
|
||||
|
||||
// signIn godoc
|
||||
// SignIn godoc
|
||||
//
|
||||
// @Summary Sign-in to memos.
|
||||
// @Tags auth
|
||||
@@ -51,7 +51,7 @@ func (s *APIV1Service) registerAuthRoutes(g *echo.Group) {
|
||||
// @Failure 403 {object} nil "User has been archived with username %s"
|
||||
// @Failure 500 {object} nil "Failed to find system setting | Failed to unmarshal system setting | Incorrect login credentials, please try again | Failed to generate tokens | Failed to create activity"
|
||||
// @Router /api/v1/auth/signin [POST]
|
||||
func (s *APIV1Service) signIn(c echo.Context) error {
|
||||
func (s *APIV1Service) SignIn(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
signin := &SignIn{}
|
||||
|
||||
@@ -104,7 +104,7 @@ func (s *APIV1Service) signIn(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, userMessage)
|
||||
}
|
||||
|
||||
// signInSSO godoc
|
||||
// SignInSSO godoc
|
||||
//
|
||||
// @Summary Sign-in to memos using SSO.
|
||||
// @Tags auth
|
||||
@@ -118,7 +118,7 @@ func (s *APIV1Service) signIn(c echo.Context) error {
|
||||
// @Failure 404 {object} nil "Identity provider not found"
|
||||
// @Failure 500 {object} nil "Failed to find identity provider | Failed to create identity provider instance | Failed to exchange token | Failed to get user info | Failed to compile identifier filter | Incorrect login credentials, please try again | Failed to generate random password | Failed to generate password hash | Failed to create user | Failed to generate tokens | Failed to create activity"
|
||||
// @Router /api/v1/auth/signin/sso [POST]
|
||||
func (s *APIV1Service) signInSSO(c echo.Context) error {
|
||||
func (s *APIV1Service) SignInSSO(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
signin := &SSOSignIn{}
|
||||
if err := json.NewDecoder(c.Request().Body).Decode(signin); err != nil {
|
||||
@@ -205,19 +205,19 @@ func (s *APIV1Service) signInSSO(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, userMessage)
|
||||
}
|
||||
|
||||
// signOut godoc
|
||||
// SignOut godoc
|
||||
//
|
||||
// @Summary Sign-out from memos.
|
||||
// @Tags auth
|
||||
// @Produce json
|
||||
// @Success 200 {boolean} true "Sign-out success"
|
||||
// @Router /api/v1/auth/signout [POST]
|
||||
func (*APIV1Service) signOut(c echo.Context) error {
|
||||
func (*APIV1Service) SignOut(c echo.Context) error {
|
||||
RemoveTokensAndCookies(c)
|
||||
return c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// signUp godoc
|
||||
// SignUp godoc
|
||||
//
|
||||
// @Summary Sign-up to memos.
|
||||
// @Tags auth
|
||||
@@ -231,7 +231,7 @@ func (*APIV1Service) signOut(c echo.Context) error {
|
||||
// @Failure 404 {object} nil "Not found"
|
||||
// @Failure 500 {object} nil "Failed to find system setting | Failed to unmarshal system setting allow signup | Failed to generate password hash | Failed to create user | Failed to generate tokens | Failed to create activity"
|
||||
// @Router /api/v1/auth/signup [POST]
|
||||
func (s *APIV1Service) signUp(c echo.Context) error {
|
||||
func (s *APIV1Service) SignUp(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
signup := &SignUp{}
|
||||
if err := json.NewDecoder(c.Request().Body).Decode(signup); err != nil {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
// Code generated by swaggo/swag. DO NOT EDIT.
|
||||
|
||||
package api
|
||||
package v1
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
|
||||
@@ -23,6 +23,50 @@ const docTemplate = `{
|
||||
"host": "{{.Host}}",
|
||||
"basePath": "{{.BasePath}}",
|
||||
"paths": {
|
||||
"/api/v1/GetSystemStatus": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"system"
|
||||
],
|
||||
"summary": "Get system GetSystemStatus",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "System GetSystemStatus",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.SystemStatus"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Missing user in session | Unauthorized"
|
||||
},
|
||||
"500": {
|
||||
"description": "Failed to find host user | Failed to find system setting list | Failed to unmarshal system setting customized profile value"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/PingSystem": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"system"
|
||||
],
|
||||
"summary": "Ping the system",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "System profile",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/profile.Profile"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/auth/signin": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
@@ -1108,25 +1152,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/ping": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"system"
|
||||
],
|
||||
"summary": "Ping the system",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "System profile",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/profile.Profile"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/resource": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -1361,31 +1386,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/status": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"system"
|
||||
],
|
||||
"summary": "Get system status",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "System status",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/v1.SystemStatus"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Missing user in session | Unauthorized"
|
||||
},
|
||||
"500": {
|
||||
"description": "Failed to find host user | Failed to find system setting list | Failed to unmarshal system setting customized profile value"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/storage": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -1555,6 +1555,36 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/system/ExecVacuum": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"system"
|
||||
],
|
||||
"summary": "Vacuum the database",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Database vacuumed",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Missing user in session | Unauthorized"
|
||||
},
|
||||
"500": {
|
||||
"description": "Failed to find user | Failed to ExecVacuum database"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/system/setting": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -1636,36 +1666,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/system/vacuum": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"system"
|
||||
],
|
||||
"summary": "Vacuum the database",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Database vacuumed",
|
||||
"schema": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "Missing user in session | Unauthorized"
|
||||
},
|
||||
"500": {
|
||||
"description": "Failed to find user | Failed to vacuum database"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/tag": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -1972,7 +1972,7 @@ const docTemplate = `{
|
||||
"tags": [
|
||||
"user-setting"
|
||||
],
|
||||
"summary": "Create user setting",
|
||||
"summary": "Upsert user setting",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Request object.",
|
||||
@@ -2144,7 +2144,38 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/o/get/httpmeta": {
|
||||
"/o/get/GetImage": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"GetImage/*"
|
||||
],
|
||||
"tags": [
|
||||
"get"
|
||||
],
|
||||
"summary": "Get GetImage from URL",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Image url",
|
||||
"name": "url",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Image"
|
||||
},
|
||||
"400": {
|
||||
"description": "Missing GetImage url | Wrong url | Failed to get GetImage url: %s"
|
||||
},
|
||||
"500": {
|
||||
"description": "Failed to write GetImage blob"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/o/get/GetWebsiteMetadata": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
@@ -2178,37 +2209,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/o/get/image": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"image/*"
|
||||
],
|
||||
"tags": [
|
||||
"get"
|
||||
],
|
||||
"summary": "Get image from URL",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Image url",
|
||||
"name": "url",
|
||||
"in": "query",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Image"
|
||||
},
|
||||
"400": {
|
||||
"description": "Missing image url | Wrong url | Failed to get image url: %s"
|
||||
},
|
||||
"500": {
|
||||
"description": "Failed to write image blob"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/o/r/{resourceId}": {
|
||||
"get": {
|
||||
"description": "*Swagger UI may have problems displaying other file types than images",
|
@@ -11,13 +11,13 @@ import (
|
||||
|
||||
func (*APIV1Service) registerGetterPublicRoutes(g *echo.Group) {
|
||||
// GET /get/httpmeta?url={url} - Get website meta.
|
||||
g.GET("/get/httpmeta", httpmeta)
|
||||
g.GET("/get/httpmeta", GetWebsiteMetadata)
|
||||
|
||||
// GET /get/image?url={url} - Get image.
|
||||
g.GET("/get/image", image)
|
||||
g.GET("/get/image", GetImage)
|
||||
}
|
||||
|
||||
// httpmeta godoc
|
||||
// GetWebsiteMetadata godoc
|
||||
//
|
||||
// @Summary Get website metadata
|
||||
// @Tags get
|
||||
@@ -26,8 +26,8 @@ func (*APIV1Service) registerGetterPublicRoutes(g *echo.Group) {
|
||||
// @Success 200 {object} getter.HTMLMeta "Extracted metadata"
|
||||
// @Failure 400 {object} nil "Missing website url | Wrong url"
|
||||
// @Failure 406 {object} nil "Failed to get website meta with url: %s"
|
||||
// @Router /o/get/httpmeta [GET]
|
||||
func httpmeta(c echo.Context) error {
|
||||
// @Router /o/get/GetWebsiteMetadata [GET]
|
||||
func GetWebsiteMetadata(c echo.Context) error {
|
||||
urlStr := c.QueryParam("url")
|
||||
if urlStr == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Missing website url")
|
||||
@@ -43,17 +43,17 @@ func httpmeta(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, htmlMeta)
|
||||
}
|
||||
|
||||
// image godoc
|
||||
// GetImage godoc
|
||||
//
|
||||
// @Summary Get image from URL
|
||||
// @Summary Get GetImage from URL
|
||||
// @Tags get
|
||||
// @Produce image/*
|
||||
// @Produce GetImage/*
|
||||
// @Param url query string true "Image url"
|
||||
// @Success 200 {object} nil "Image"
|
||||
// @Failure 400 {object} nil "Missing image url | Wrong url | Failed to get image url: %s"
|
||||
// @Failure 500 {object} nil "Failed to write image blob"
|
||||
// @Router /o/get/image [GET]
|
||||
func image(c echo.Context) error {
|
||||
// @Failure 400 {object} nil "Missing GetImage url | Wrong url | Failed to get GetImage url: %s"
|
||||
// @Failure 500 {object} nil "Failed to write GetImage blob"
|
||||
// @Router /o/get/GetImage [GET]
|
||||
func GetImage(c echo.Context) error {
|
||||
urlStr := c.QueryParam("url")
|
||||
if urlStr == "" {
|
||||
return echo.NewHTTPError(http.StatusBadRequest, "Missing image url")
|
||||
|
@@ -65,15 +65,14 @@ type UpdateIdentityProviderRequest struct {
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerIdentityProviderRoutes(g *echo.Group) {
|
||||
g.GET("/idp", s.getIdentityProviderList)
|
||||
g.POST("/idp", s.createIdentityProvider)
|
||||
|
||||
g.GET("/idp/:idpId", s.getIdentityProvider)
|
||||
g.DELETE("/idp/:idpId", s.deleteIdentityProvider)
|
||||
g.PATCH("/idp/:idpId", s.updateIdentityProvider)
|
||||
g.GET("/idp", s.GetIdentityProviderList)
|
||||
g.POST("/idp", s.CreateIdentityProvider)
|
||||
g.GET("/idp/:idpId", s.GetIdentityProvider)
|
||||
g.PATCH("/idp/:idpId", s.UpdateIdentityProvider)
|
||||
g.DELETE("/idp/:idpId", s.DeleteIdentityProvider)
|
||||
}
|
||||
|
||||
// getIdentityProviderList godoc
|
||||
// GetIdentityProviderList godoc
|
||||
//
|
||||
// @Summary Get a list of identity providers
|
||||
// @Description *clientSecret is only available for host user
|
||||
@@ -82,7 +81,7 @@ func (s *APIV1Service) registerIdentityProviderRoutes(g *echo.Group) {
|
||||
// @Success 200 {object} []IdentityProvider "List of available identity providers"
|
||||
// @Failure 500 {object} nil "Failed to find identity provider list | Failed to find user"
|
||||
// @Router /api/v1/idp [GET]
|
||||
func (s *APIV1Service) getIdentityProviderList(c echo.Context) error {
|
||||
func (s *APIV1Service) GetIdentityProviderList(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
list, err := s.Store.ListIdentityProviders(ctx, &store.FindIdentityProvider{})
|
||||
if err != nil {
|
||||
@@ -115,7 +114,7 @@ func (s *APIV1Service) getIdentityProviderList(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, identityProviderList)
|
||||
}
|
||||
|
||||
// createIdentityProvider godoc
|
||||
// CreateIdentityProvider godoc
|
||||
//
|
||||
// @Summary Create Identity Provider
|
||||
// @Tags idp
|
||||
@@ -128,7 +127,7 @@ func (s *APIV1Service) getIdentityProviderList(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to create identity provider"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/idp [POST]
|
||||
func (s *APIV1Service) createIdentityProvider(c echo.Context) error {
|
||||
func (s *APIV1Service) CreateIdentityProvider(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -162,7 +161,7 @@ func (s *APIV1Service) createIdentityProvider(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, convertIdentityProviderFromStore(identityProvider))
|
||||
}
|
||||
|
||||
// getIdentityProvider godoc
|
||||
// GetIdentityProvider godoc
|
||||
//
|
||||
// @Summary Get an identity provider by ID
|
||||
// @Tags idp
|
||||
@@ -176,7 +175,7 @@ func (s *APIV1Service) createIdentityProvider(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find identity provider list | Failed to find user"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/idp/{idpId} [GET]
|
||||
func (s *APIV1Service) getIdentityProvider(c echo.Context) error {
|
||||
func (s *APIV1Service) GetIdentityProvider(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -210,7 +209,7 @@ func (s *APIV1Service) getIdentityProvider(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, convertIdentityProviderFromStore(identityProvider))
|
||||
}
|
||||
|
||||
// deleteIdentityProvider godoc
|
||||
// DeleteIdentityProvider godoc
|
||||
//
|
||||
// @Summary Delete an identity provider by ID
|
||||
// @Tags idp
|
||||
@@ -223,7 +222,7 @@ func (s *APIV1Service) getIdentityProvider(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to patch identity provider"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/idp/{idpId} [DELETE]
|
||||
func (s *APIV1Service) deleteIdentityProvider(c echo.Context) error {
|
||||
func (s *APIV1Service) DeleteIdentityProvider(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -251,7 +250,7 @@ func (s *APIV1Service) deleteIdentityProvider(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// updateIdentityProvider godoc
|
||||
// UpdateIdentityProvider godoc
|
||||
//
|
||||
// @Summary Update an identity provider by ID
|
||||
// @Tags idp
|
||||
@@ -265,7 +264,7 @@ func (s *APIV1Service) deleteIdentityProvider(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to patch identity provider"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/idp/{idpId} [PATCH]
|
||||
func (s *APIV1Service) updateIdentityProvider(c echo.Context) error {
|
||||
func (s *APIV1Service) UpdateIdentityProvider(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
|
@@ -113,17 +113,16 @@ type FindMemoRequest struct {
|
||||
const maxContentLength = 1 << 30
|
||||
|
||||
func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {
|
||||
g.GET("/memo", s.getMemoList)
|
||||
g.POST("/memo", s.createMemo)
|
||||
g.GET("/memo/all", s.getAllMemos)
|
||||
g.GET("/memo/stats", s.getMemoStats)
|
||||
|
||||
g.GET("/memo/:memoId", s.getMemo)
|
||||
g.DELETE("/memo/:memoId", s.deleteMemo)
|
||||
g.PATCH("/memo/:memoId", s.updateMemo)
|
||||
g.GET("/memo", s.GetMemoList)
|
||||
g.POST("/memo", s.CreateMemo)
|
||||
g.GET("/memo/all", s.GetAllMemos)
|
||||
g.GET("/memo/stats", s.GetMemoStats)
|
||||
g.GET("/memo/:memoId", s.GetMemo)
|
||||
g.PATCH("/memo/:memoId", s.UpdateMemo)
|
||||
g.DELETE("/memo/:memoId", s.DeleteMemo)
|
||||
}
|
||||
|
||||
// getMemoList godoc
|
||||
// GetMemoList godoc
|
||||
//
|
||||
// @Summary Get a list of memos matching optional filters
|
||||
// @Tags memo
|
||||
@@ -141,7 +140,7 @@ func (s *APIV1Service) registerMemoRoutes(g *echo.Group) {
|
||||
// @Failure 500 {object} nil "Failed to get memo display with updated ts setting value | Failed to fetch memo list | Failed to compose memo response"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/memo [GET]
|
||||
func (s *APIV1Service) getMemoList(c echo.Context) error {
|
||||
func (s *APIV1Service) GetMemoList(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
findMemoMessage := &store.FindMemo{}
|
||||
if userID, err := util.ConvertStringToInt32(c.QueryParam("creatorId")); err == nil {
|
||||
@@ -225,7 +224,7 @@ func (s *APIV1Service) getMemoList(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, memoResponseList)
|
||||
}
|
||||
|
||||
// createMemo godoc
|
||||
// CreateMemo godoc
|
||||
//
|
||||
// @Summary Create a memo
|
||||
// @Description Visibility can be PUBLIC, PROTECTED or PRIVATE
|
||||
@@ -244,7 +243,7 @@ func (s *APIV1Service) getMemoList(c echo.Context) error {
|
||||
//
|
||||
// NOTES:
|
||||
// - It's currently possible to create phantom resources and relations. Phantom relations will trigger backend 404's when fetching memo.
|
||||
func (s *APIV1Service) createMemo(c echo.Context) error {
|
||||
func (s *APIV1Service) CreateMemo(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -355,7 +354,7 @@ func (s *APIV1Service) createMemo(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, memoResponse)
|
||||
}
|
||||
|
||||
// getAllMemos godoc
|
||||
// GetAllMemos godoc
|
||||
//
|
||||
// @Summary Get a list of public memos matching optional filters
|
||||
// @Description This should also list protected memos if the user is logged in
|
||||
@@ -371,7 +370,7 @@ func (s *APIV1Service) createMemo(c echo.Context) error {
|
||||
//
|
||||
// NOTES:
|
||||
// - creatorUsername is listed at ./web/src/helpers/api.ts:82, but it's not present here
|
||||
func (s *APIV1Service) getAllMemos(c echo.Context) error {
|
||||
func (s *APIV1Service) GetAllMemos(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
findMemoMessage := &store.FindMemo{}
|
||||
_, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
@@ -415,7 +414,7 @@ func (s *APIV1Service) getAllMemos(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, memoResponseList)
|
||||
}
|
||||
|
||||
// getMemoStats godoc
|
||||
// GetMemoStats godoc
|
||||
//
|
||||
// @Summary Get memo stats by creator ID or username
|
||||
// @Description Used to generate the heatmap
|
||||
@@ -427,7 +426,7 @@ func (s *APIV1Service) getAllMemos(c echo.Context) error {
|
||||
// @Failure 400 {object} nil "Missing user id to find memo"
|
||||
// @Failure 500 {object} nil "Failed to get memo display with updated ts setting value | Failed to find memo list | Failed to compose memo response"
|
||||
// @Router /api/v1/memo/stats [GET]
|
||||
func (s *APIV1Service) getMemoStats(c echo.Context) error {
|
||||
func (s *APIV1Service) GetMemoStats(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
normalStatus := store.Normal
|
||||
findMemoMessage := &store.FindMemo{
|
||||
@@ -487,7 +486,7 @@ func (s *APIV1Service) getMemoStats(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, displayTsList)
|
||||
}
|
||||
|
||||
// getMemo godoc
|
||||
// GetMemo godoc
|
||||
//
|
||||
// @Summary Get memo by ID
|
||||
// @Tags memo
|
||||
@@ -500,7 +499,7 @@ func (s *APIV1Service) getMemoStats(c echo.Context) error {
|
||||
// @Failure 404 {object} nil "Memo not found: %d"
|
||||
// @Failure 500 {object} nil "Failed to find memo by ID: %v | Failed to compose memo response"
|
||||
// @Router /api/v1/memo/{memoId} [GET]
|
||||
func (s *APIV1Service) getMemo(c echo.Context) error {
|
||||
func (s *APIV1Service) GetMemo(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
memoID, err := util.ConvertStringToInt32(c.Param("memoId"))
|
||||
if err != nil {
|
||||
@@ -534,7 +533,7 @@ func (s *APIV1Service) getMemo(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, memoResponse)
|
||||
}
|
||||
|
||||
// deleteMemo godoc
|
||||
// DeleteMemo godoc
|
||||
//
|
||||
// @Summary Delete memo by ID
|
||||
// @Tags memo
|
||||
@@ -547,7 +546,7 @@ func (s *APIV1Service) getMemo(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find memo | Failed to delete memo ID: %v"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/memo/{memoId} [DELETE]
|
||||
func (s *APIV1Service) deleteMemo(c echo.Context) error {
|
||||
func (s *APIV1Service) DeleteMemo(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -579,7 +578,7 @@ func (s *APIV1Service) deleteMemo(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// updateMemo godoc
|
||||
// UpdateMemo godoc
|
||||
//
|
||||
// @Summary Update a memo
|
||||
// @Description Visibility can be PUBLIC, PROTECTED or PRIVATE
|
||||
@@ -600,7 +599,7 @@ func (s *APIV1Service) deleteMemo(c echo.Context) error {
|
||||
// NOTES:
|
||||
// - It's currently possible to create phantom resources and relations. Phantom relations will trigger backend 404's when fetching memo.
|
||||
// - Passing 0 to createdTs and updatedTs will set them to 0 in the database, which is probably unwanted.
|
||||
func (s *APIV1Service) updateMemo(c echo.Context) error {
|
||||
func (s *APIV1Service) UpdateMemo(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
|
@@ -22,10 +22,10 @@ type UpsertMemoOrganizerRequest struct {
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerMemoOrganizerRoutes(g *echo.Group) {
|
||||
g.POST("/memo/:memoId/organizer", s.organizeMemo)
|
||||
g.POST("/memo/:memoId/organizer", s.CreateMemoOrganizer)
|
||||
}
|
||||
|
||||
// organizeMemo godoc
|
||||
// CreateMemoOrganizer godoc
|
||||
//
|
||||
// @Summary Organize memo (pin/unpin)
|
||||
// @Tags memo-organizer
|
||||
@@ -40,7 +40,7 @@ func (s *APIV1Service) registerMemoOrganizerRoutes(g *echo.Group) {
|
||||
// @Failure 500 {object} nil "Failed to find memo | Failed to upsert memo organizer | Failed to find memo by ID: %v | Failed to compose memo response"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/memo/{memoId}/organizer [POST]
|
||||
func (s *APIV1Service) organizeMemo(c echo.Context) error {
|
||||
func (s *APIV1Service) CreateMemoOrganizer(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
memoID, err := util.ConvertStringToInt32(c.Param("memoId"))
|
||||
if err != nil {
|
||||
|
@@ -29,12 +29,12 @@ type UpsertMemoRelationRequest struct {
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerMemoRelationRoutes(g *echo.Group) {
|
||||
g.GET("/memo/:memoId/relation", s.getMemoRelationList)
|
||||
g.POST("/memo/:memoId/relation", s.createMemoRelation)
|
||||
g.DELETE("/memo/:memoId/relation/:relatedMemoId/type/:relationType", s.deleteMemoRelation)
|
||||
g.GET("/memo/:memoId/relation", s.GetMemoRelationList)
|
||||
g.POST("/memo/:memoId/relation", s.CreateMemoRelation)
|
||||
g.DELETE("/memo/:memoId/relation/:relatedMemoId/type/:relationType", s.DeleteMemoRelation)
|
||||
}
|
||||
|
||||
// getMemoRelationList godoc
|
||||
// GetMemoRelationList godoc
|
||||
//
|
||||
// @Summary Get a list of Memo Relations
|
||||
// @Tags memo-relation
|
||||
@@ -45,7 +45,7 @@ func (s *APIV1Service) registerMemoRelationRoutes(g *echo.Group) {
|
||||
// @Failure 400 {object} nil "ID is not a number: %s"
|
||||
// @Failure 500 {object} nil "Failed to list memo relations"
|
||||
// @Router /api/v1/memo/{memoId}/relation [GET]
|
||||
func (s *APIV1Service) getMemoRelationList(c echo.Context) error {
|
||||
func (s *APIV1Service) GetMemoRelationList(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
memoID, err := util.ConvertStringToInt32(c.Param("memoId"))
|
||||
if err != nil {
|
||||
@@ -61,7 +61,7 @@ func (s *APIV1Service) getMemoRelationList(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, memoRelationList)
|
||||
}
|
||||
|
||||
// createMemoRelation godoc
|
||||
// CreateMemoRelation godoc
|
||||
//
|
||||
// @Summary Create Memo Relation
|
||||
// @Description Create a relation between two memos
|
||||
@@ -79,7 +79,7 @@ func (s *APIV1Service) getMemoRelationList(c echo.Context) error {
|
||||
// - Currently not secured
|
||||
// - It's possible to create relations to memos that doesn't exist, which will trigger 404 errors when the frontend tries to load them.
|
||||
// - It's possible to create multiple relations, though the interface only shows first.
|
||||
func (s *APIV1Service) createMemoRelation(c echo.Context) error {
|
||||
func (s *APIV1Service) CreateMemoRelation(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
memoID, err := util.ConvertStringToInt32(c.Param("memoId"))
|
||||
if err != nil {
|
||||
@@ -102,7 +102,7 @@ func (s *APIV1Service) createMemoRelation(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, memoRelation)
|
||||
}
|
||||
|
||||
// deleteMemoRelation godoc
|
||||
// DeleteMemoRelation godoc
|
||||
//
|
||||
// @Summary Delete a Memo Relation
|
||||
// @Description Removes a relation between two memos
|
||||
@@ -120,7 +120,7 @@ func (s *APIV1Service) createMemoRelation(c echo.Context) error {
|
||||
// NOTES:
|
||||
// - Currently not secured.
|
||||
// - Will always return true, even if the relation doesn't exist.
|
||||
func (s *APIV1Service) deleteMemoRelation(c echo.Context) error {
|
||||
func (s *APIV1Service) DeleteMemoRelation(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
memoID, err := util.ConvertStringToInt32(c.Param("memoId"))
|
||||
if err != nil {
|
||||
|
@@ -35,12 +35,12 @@ type MemoResourceDelete struct {
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerMemoResourceRoutes(g *echo.Group) {
|
||||
g.GET("/memo/:memoId/resource", s.getMemoResourceList)
|
||||
g.POST("/memo/:memoId/resource", s.bindMemoResource)
|
||||
g.DELETE("/memo/:memoId/resource/:resourceId", s.unbindMemoResource)
|
||||
g.GET("/memo/:memoId/resource", s.GetMemoResourceList)
|
||||
g.POST("/memo/:memoId/resource", s.BindMemoResource)
|
||||
g.DELETE("/memo/:memoId/resource/:resourceId", s.UnbindMemoResource)
|
||||
}
|
||||
|
||||
// getMemoResourceList godoc
|
||||
// GetMemoResourceList godoc
|
||||
//
|
||||
// @Summary Get resource list of a memo
|
||||
// @Tags memo-resource
|
||||
@@ -51,7 +51,7 @@ func (s *APIV1Service) registerMemoResourceRoutes(g *echo.Group) {
|
||||
// @Failure 400 {object} nil "ID is not a number: %s"
|
||||
// @Failure 500 {object} nil "Failed to fetch resource list"
|
||||
// @Router /api/v1/memo/{memoId}/resource [GET]
|
||||
func (s *APIV1Service) getMemoResourceList(c echo.Context) error {
|
||||
func (s *APIV1Service) GetMemoResourceList(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
memoID, err := util.ConvertStringToInt32(c.Param("memoId"))
|
||||
if err != nil {
|
||||
@@ -71,7 +71,7 @@ func (s *APIV1Service) getMemoResourceList(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, resourceList)
|
||||
}
|
||||
|
||||
// bindMemoResource godoc
|
||||
// BindMemoResource godoc
|
||||
//
|
||||
// @Summary Bind resource to memo
|
||||
// @Tags memo-resource
|
||||
@@ -88,7 +88,7 @@ func (s *APIV1Service) getMemoResourceList(c echo.Context) error {
|
||||
//
|
||||
// NOTES:
|
||||
// - Passing 0 to updatedTs will set it to 0 in the database, which is probably unwanted.
|
||||
func (s *APIV1Service) bindMemoResource(c echo.Context) error {
|
||||
func (s *APIV1Service) BindMemoResource(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
memoID, err := util.ConvertStringToInt32(c.Param("memoId"))
|
||||
if err != nil {
|
||||
@@ -129,7 +129,7 @@ func (s *APIV1Service) bindMemoResource(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// unbindMemoResource godoc
|
||||
// UnbindMemoResource godoc
|
||||
//
|
||||
// @Summary Unbind resource from memo
|
||||
// @Tags memo-resource
|
||||
@@ -143,7 +143,7 @@ func (s *APIV1Service) bindMemoResource(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find memo | Failed to fetch resource list"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/memo/{memoId}/resource/{resourceId} [DELETE]
|
||||
func (s *APIV1Service) unbindMemoResource(c echo.Context) error {
|
||||
func (s *APIV1Service) UnbindMemoResource(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
|
@@ -81,11 +81,11 @@ const (
|
||||
var fileKeyPattern = regexp.MustCompile(`\{[a-z]{1,9}\}`)
|
||||
|
||||
func (s *APIV1Service) registerResourceRoutes(g *echo.Group) {
|
||||
g.GET("/resource", s.getResourceList)
|
||||
g.POST("/resource", s.createResource)
|
||||
g.POST("/resource/blob", s.uploadResource)
|
||||
g.DELETE("/resource/:resourceId", s.deleteResource)
|
||||
g.PATCH("/resource/:resourceId", s.updateResource)
|
||||
g.GET("/resource", s.GetResourceList)
|
||||
g.POST("/resource", s.CreateResource)
|
||||
g.POST("/resource/blob", s.UploadResource)
|
||||
g.PATCH("/resource/:resourceId", s.UpdateResource)
|
||||
g.DELETE("/resource/:resourceId", s.DeleteResource)
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerResourcePublicRoutes(g *echo.Group) {
|
||||
@@ -93,7 +93,7 @@ func (s *APIV1Service) registerResourcePublicRoutes(g *echo.Group) {
|
||||
g.GET("/r/:resourceId/*", s.streamResource)
|
||||
}
|
||||
|
||||
// getResourceList godoc
|
||||
// GetResourceList godoc
|
||||
//
|
||||
// @Summary Get a list of resources
|
||||
// @Tags resource
|
||||
@@ -105,7 +105,7 @@ func (s *APIV1Service) registerResourcePublicRoutes(g *echo.Group) {
|
||||
// @Failure 500 {object} nil "Failed to fetch resource list"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/resource [GET]
|
||||
func (s *APIV1Service) getResourceList(c echo.Context) error {
|
||||
func (s *APIV1Service) GetResourceList(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -132,7 +132,7 @@ func (s *APIV1Service) getResourceList(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, resourceMessageList)
|
||||
}
|
||||
|
||||
// createResource godoc
|
||||
// CreateResource godoc
|
||||
//
|
||||
// @Summary Create resource
|
||||
// @Tags resource
|
||||
@@ -145,7 +145,7 @@ func (s *APIV1Service) getResourceList(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to save resource | Failed to create resource | Failed to create activity"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/resource [POST]
|
||||
func (s *APIV1Service) createResource(c echo.Context) error {
|
||||
func (s *APIV1Service) CreateResource(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -219,7 +219,7 @@ func (s *APIV1Service) createResource(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, convertResourceFromStore(resource))
|
||||
}
|
||||
|
||||
// uploadResource godoc
|
||||
// UploadResource godoc
|
||||
//
|
||||
// @Summary Upload resource
|
||||
// @Tags resource
|
||||
@@ -232,7 +232,7 @@ func (s *APIV1Service) createResource(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to get uploading file | Failed to open file | Failed to save resource | Failed to create resource | Failed to create activity"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/resource/blob [POST]
|
||||
func (s *APIV1Service) uploadResource(c echo.Context) error {
|
||||
func (s *APIV1Service) UploadResource(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -292,7 +292,7 @@ func (s *APIV1Service) uploadResource(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, convertResourceFromStore(resource))
|
||||
}
|
||||
|
||||
// deleteResource godoc
|
||||
// DeleteResource godoc
|
||||
//
|
||||
// @Summary Delete a resource
|
||||
// @Tags resource
|
||||
@@ -305,7 +305,7 @@ func (s *APIV1Service) uploadResource(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find resource | Failed to delete resource"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/resource/{resourceId} [DELETE]
|
||||
func (s *APIV1Service) deleteResource(c echo.Context) error {
|
||||
func (s *APIV1Service) DeleteResource(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -348,7 +348,7 @@ func (s *APIV1Service) deleteResource(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// updateResource godoc
|
||||
// UpdateResource godoc
|
||||
//
|
||||
// @Summary Update a resource
|
||||
// @Tags resource
|
||||
@@ -362,7 +362,7 @@ func (s *APIV1Service) deleteResource(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find resource | Failed to patch resource"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/resource/{resourceId} [PATCH]
|
||||
func (s *APIV1Service) updateResource(c echo.Context) error {
|
||||
func (s *APIV1Service) UpdateResource(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
|
@@ -21,11 +21,11 @@ const maxRSSItemCount = 100
|
||||
const maxRSSItemTitleLength = 100
|
||||
|
||||
func (s *APIV1Service) registerRSSRoutes(g *echo.Group) {
|
||||
g.GET("/explore/rss.xml", s.getRSS)
|
||||
g.GET("/u/:id/rss.xml", s.getUserRSS)
|
||||
g.GET("/explore/rss.xml", s.GetExploreRSS)
|
||||
g.GET("/u/:id/rss.xml", s.GetUserRSS)
|
||||
}
|
||||
|
||||
// getRSS godoc
|
||||
// GetExploreRSS godoc
|
||||
//
|
||||
// @Summary Get RSS
|
||||
// @Tags rss
|
||||
@@ -33,7 +33,7 @@ func (s *APIV1Service) registerRSSRoutes(g *echo.Group) {
|
||||
// @Success 200 {object} nil "RSS"
|
||||
// @Failure 500 {object} nil "Failed to get system customized profile | Failed to find memo list | Failed to generate rss"
|
||||
// @Router /explore/rss.xml [GET]
|
||||
func (s *APIV1Service) getRSS(c echo.Context) error {
|
||||
func (s *APIV1Service) GetExploreRSS(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
systemCustomizedProfile, err := s.getSystemCustomizedProfile(ctx)
|
||||
if err != nil {
|
||||
@@ -59,7 +59,7 @@ func (s *APIV1Service) getRSS(c echo.Context) error {
|
||||
return c.String(http.StatusOK, rss)
|
||||
}
|
||||
|
||||
// getUserRSS godoc
|
||||
// GetUserRSS godoc
|
||||
//
|
||||
// @Summary Get RSS for a user
|
||||
// @Tags rss
|
||||
@@ -69,7 +69,7 @@ func (s *APIV1Service) getRSS(c echo.Context) error {
|
||||
// @Failure 400 {object} nil "User id is not a number"
|
||||
// @Failure 500 {object} nil "Failed to get system customized profile | Failed to find memo list | Failed to generate rss"
|
||||
// @Router /u/{id}/rss.xml [GET]
|
||||
func (s *APIV1Service) getUserRSS(c echo.Context) error {
|
||||
func (s *APIV1Service) GetUserRSS(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
id, err := util.ConvertStringToInt32(c.Param("id"))
|
||||
if err != nil {
|
||||
|
@@ -63,13 +63,13 @@ type UpdateStorageRequest struct {
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerStorageRoutes(g *echo.Group) {
|
||||
g.GET("/storage", s.getStorageList)
|
||||
g.POST("/storage", s.createStorage)
|
||||
g.DELETE("/storage/:storageId", s.deleteStorage)
|
||||
g.PATCH("/storage/:storageId", s.updateStorage)
|
||||
g.GET("/storage", s.GetStorageList)
|
||||
g.POST("/storage", s.CreateStorage)
|
||||
g.PATCH("/storage/:storageId", s.UpdateStorage)
|
||||
g.DELETE("/storage/:storageId", s.DeleteStorage)
|
||||
}
|
||||
|
||||
// getStorageList godoc
|
||||
// GetStorageList godoc
|
||||
//
|
||||
// @Summary Get a list of storages
|
||||
// @Tags storage
|
||||
@@ -79,7 +79,7 @@ func (s *APIV1Service) registerStorageRoutes(g *echo.Group) {
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to convert storage"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/storage [GET]
|
||||
func (s *APIV1Service) getStorageList(c echo.Context) error {
|
||||
func (s *APIV1Service) GetStorageList(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -113,7 +113,7 @@ func (s *APIV1Service) getStorageList(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, storageList)
|
||||
}
|
||||
|
||||
// createStorage godoc
|
||||
// CreateStorage godoc
|
||||
//
|
||||
// @Summary Create storage
|
||||
// @Tags storage
|
||||
@@ -126,7 +126,7 @@ func (s *APIV1Service) getStorageList(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to create storage | Failed to convert storage"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/storage [POST]
|
||||
func (s *APIV1Service) createStorage(c echo.Context) error {
|
||||
func (s *APIV1Service) CreateStorage(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -172,7 +172,7 @@ func (s *APIV1Service) createStorage(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, storageMessage)
|
||||
}
|
||||
|
||||
// deleteStorage godoc
|
||||
// DeleteStorage godoc
|
||||
//
|
||||
// @Summary Delete a storage
|
||||
// @Tags storage
|
||||
@@ -187,7 +187,7 @@ func (s *APIV1Service) createStorage(c echo.Context) error {
|
||||
//
|
||||
// NOTES:
|
||||
// - error message "Storage service %d is using" probably should be "Storage service %d is in use".
|
||||
func (s *APIV1Service) deleteStorage(c echo.Context) error {
|
||||
func (s *APIV1Service) DeleteStorage(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -230,7 +230,7 @@ func (s *APIV1Service) deleteStorage(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// updateStorage godoc
|
||||
// UpdateStorage godoc
|
||||
//
|
||||
// @Summary Update a storage
|
||||
// @Tags storage
|
||||
@@ -243,7 +243,7 @@ func (s *APIV1Service) deleteStorage(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to patch storage | Failed to convert storage"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/storage/{storageId} [PATCH]
|
||||
func (s *APIV1Service) updateStorage(c echo.Context) error {
|
||||
func (s *APIV1Service) UpdateStorage(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
|
@@ -748,6 +748,35 @@ info:
|
||||
title: memos API
|
||||
version: "1.0"
|
||||
paths:
|
||||
/api/v1/GetSystemStatus:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: System GetSystemStatus
|
||||
schema:
|
||||
$ref: '#/definitions/v1.SystemStatus'
|
||||
"401":
|
||||
description: Missing user in session | Unauthorized
|
||||
"500":
|
||||
description: Failed to find host user | Failed to find system setting list
|
||||
| Failed to unmarshal system setting customized profile value
|
||||
summary: Get system GetSystemStatus
|
||||
tags:
|
||||
- system
|
||||
/api/v1/PingSystem:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: System profile
|
||||
schema:
|
||||
$ref: '#/definitions/profile.Profile'
|
||||
summary: Ping the system
|
||||
tags:
|
||||
- system
|
||||
/api/v1/auth/signin:
|
||||
post:
|
||||
consumes:
|
||||
@@ -1480,18 +1509,6 @@ paths:
|
||||
summary: Get memo stats by creator ID or username
|
||||
tags:
|
||||
- memo
|
||||
/api/v1/ping:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: System profile
|
||||
schema:
|
||||
$ref: '#/definitions/profile.Profile'
|
||||
summary: Ping the system
|
||||
tags:
|
||||
- system
|
||||
/api/v1/resource:
|
||||
get:
|
||||
parameters:
|
||||
@@ -1643,23 +1660,6 @@ paths:
|
||||
summary: Upload resource
|
||||
tags:
|
||||
- resource
|
||||
/api/v1/status:
|
||||
get:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: System status
|
||||
schema:
|
||||
$ref: '#/definitions/v1.SystemStatus'
|
||||
"401":
|
||||
description: Missing user in session | Unauthorized
|
||||
"500":
|
||||
description: Failed to find host user | Failed to find system setting list
|
||||
| Failed to unmarshal system setting customized profile value
|
||||
summary: Get system status
|
||||
tags:
|
||||
- system
|
||||
/api/v1/storage:
|
||||
get:
|
||||
produces:
|
||||
@@ -1769,6 +1769,24 @@ paths:
|
||||
summary: Update a storage
|
||||
tags:
|
||||
- storage
|
||||
/api/v1/system/ExecVacuum:
|
||||
post:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Database vacuumed
|
||||
schema:
|
||||
type: boolean
|
||||
"401":
|
||||
description: Missing user in session | Unauthorized
|
||||
"500":
|
||||
description: Failed to find user | Failed to ExecVacuum database
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Vacuum the database
|
||||
tags:
|
||||
- system
|
||||
/api/v1/system/setting:
|
||||
get:
|
||||
produces:
|
||||
@@ -1819,24 +1837,6 @@ paths:
|
||||
summary: Create system setting
|
||||
tags:
|
||||
- system-setting
|
||||
/api/v1/system/vacuum:
|
||||
post:
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: Database vacuumed
|
||||
schema:
|
||||
type: boolean
|
||||
"401":
|
||||
description: Missing user in session | Unauthorized
|
||||
"500":
|
||||
description: Failed to find user | Failed to vacuum database
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Vacuum the database
|
||||
tags:
|
||||
- system
|
||||
/api/v1/tag:
|
||||
get:
|
||||
produces:
|
||||
@@ -2129,7 +2129,7 @@ paths:
|
||||
description: Failed to upsert user setting
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Create user setting
|
||||
summary: Upsert user setting
|
||||
tags:
|
||||
- user-setting
|
||||
/explore/rss.xml:
|
||||
@@ -2145,7 +2145,28 @@ paths:
|
||||
summary: Get RSS
|
||||
tags:
|
||||
- rss
|
||||
/o/get/httpmeta:
|
||||
/o/get/GetImage:
|
||||
get:
|
||||
parameters:
|
||||
- description: Image url
|
||||
in: query
|
||||
name: url
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- GetImage/*
|
||||
responses:
|
||||
"200":
|
||||
description: Image
|
||||
"400":
|
||||
description: 'Missing GetImage url | Wrong url | Failed to get GetImage
|
||||
url: %s'
|
||||
"500":
|
||||
description: Failed to write GetImage blob
|
||||
summary: Get GetImage from URL
|
||||
tags:
|
||||
- get
|
||||
/o/get/GetWebsiteMetadata:
|
||||
get:
|
||||
parameters:
|
||||
- description: Website URL
|
||||
@@ -2167,26 +2188,6 @@ paths:
|
||||
summary: Get website metadata
|
||||
tags:
|
||||
- get
|
||||
/o/get/image:
|
||||
get:
|
||||
parameters:
|
||||
- description: Image url
|
||||
in: query
|
||||
name: url
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- image/*
|
||||
responses:
|
||||
"200":
|
||||
description: Image
|
||||
"400":
|
||||
description: 'Missing image url | Wrong url | Failed to get image url: %s'
|
||||
"500":
|
||||
description: Failed to write image blob
|
||||
summary: Get image from URL
|
||||
tags:
|
||||
- get
|
||||
/o/r/{resourceId}:
|
||||
get:
|
||||
description: '*Swagger UI may have problems displaying other file types than
|
@@ -43,32 +43,32 @@ type SystemStatus struct {
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerSystemRoutes(g *echo.Group) {
|
||||
g.GET("/ping", s.ping)
|
||||
g.GET("/status", s.status)
|
||||
g.POST("/system/vacuum", s.vacuum)
|
||||
g.GET("/ping", s.PingSystem)
|
||||
g.GET("/status", s.GetSystemStatus)
|
||||
g.POST("/system/vacuum", s.ExecVacuum)
|
||||
}
|
||||
|
||||
// ping godoc
|
||||
// PingSystem godoc
|
||||
//
|
||||
// @Summary Ping the system
|
||||
// @Tags system
|
||||
// @Produce json
|
||||
// @Success 200 {object} profile.Profile "System profile"
|
||||
// @Router /api/v1/ping [GET]
|
||||
func (s *APIV1Service) ping(c echo.Context) error {
|
||||
// @Router /api/v1/PingSystem [GET]
|
||||
func (s *APIV1Service) PingSystem(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, s.Profile)
|
||||
}
|
||||
|
||||
// status godoc
|
||||
// GetSystemStatus godoc
|
||||
//
|
||||
// @Summary Get system status
|
||||
// @Summary Get system GetSystemStatus
|
||||
// @Tags system
|
||||
// @Produce json
|
||||
// @Success 200 {object} SystemStatus "System status"
|
||||
// @Success 200 {object} SystemStatus "System GetSystemStatus"
|
||||
// @Failure 401 {object} nil "Missing user in session | Unauthorized"
|
||||
// @Failure 500 {object} nil "Failed to find host user | Failed to find system setting list | Failed to unmarshal system setting customized profile value"
|
||||
// @Router /api/v1/status [GET]
|
||||
func (s *APIV1Service) status(c echo.Context) error {
|
||||
// @Router /api/v1/GetSystemStatus [GET]
|
||||
func (s *APIV1Service) GetSystemStatus(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
|
||||
systemStatus := SystemStatus{
|
||||
@@ -156,17 +156,17 @@ func (s *APIV1Service) status(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, systemStatus)
|
||||
}
|
||||
|
||||
// vacuum godoc
|
||||
// ExecVacuum godoc
|
||||
//
|
||||
// @Summary Vacuum the database
|
||||
// @Tags system
|
||||
// @Produce json
|
||||
// @Success 200 {boolean} true "Database vacuumed"
|
||||
// @Failure 401 {object} nil "Missing user in session | Unauthorized"
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to vacuum database"
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to ExecVacuum database"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/system/vacuum [POST]
|
||||
func (s *APIV1Service) vacuum(c echo.Context) error {
|
||||
// @Router /api/v1/system/ExecVacuum [POST]
|
||||
func (s *APIV1Service) ExecVacuum(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
|
@@ -79,11 +79,11 @@ type UpsertSystemSettingRequest struct {
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerSystemSettingRoutes(g *echo.Group) {
|
||||
g.GET("/system/setting", s.getSystemSettingList)
|
||||
g.POST("/system/setting", s.createSystemSetting)
|
||||
g.GET("/system/setting", s.GetSystemSettingList)
|
||||
g.POST("/system/setting", s.CreateSystemSetting)
|
||||
}
|
||||
|
||||
// getSystemSettingList godoc
|
||||
// GetSystemSettingList godoc
|
||||
//
|
||||
// @Summary Get a list of system settings
|
||||
// @Tags system-setting
|
||||
@@ -93,7 +93,7 @@ func (s *APIV1Service) registerSystemSettingRoutes(g *echo.Group) {
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to find system setting list"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/system/setting [GET]
|
||||
func (s *APIV1Service) getSystemSettingList(c echo.Context) error {
|
||||
func (s *APIV1Service) GetSystemSettingList(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -122,7 +122,7 @@ func (s *APIV1Service) getSystemSettingList(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, systemSettingList)
|
||||
}
|
||||
|
||||
// createSystemSetting godoc
|
||||
// CreateSystemSetting godoc
|
||||
//
|
||||
// @Summary Create system setting
|
||||
// @Tags system-setting
|
||||
@@ -136,7 +136,7 @@ func (s *APIV1Service) getSystemSettingList(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to upsert system setting"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/system/setting [POST]
|
||||
func (s *APIV1Service) createSystemSetting(c echo.Context) error {
|
||||
func (s *APIV1Service) CreateSystemSetting(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
|
@@ -28,13 +28,13 @@ type DeleteTagRequest struct {
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerTagRoutes(g *echo.Group) {
|
||||
g.GET("/tag", s.getTagList)
|
||||
g.POST("/tag", s.createTag)
|
||||
g.POST("/tag/delete", s.deleteTag)
|
||||
g.GET("/tag/suggestion", s.getTagSuggestion)
|
||||
g.GET("/tag", s.GetTagList)
|
||||
g.POST("/tag", s.CreateTag)
|
||||
g.GET("/tag/suggestion", s.GetTagSuggestion)
|
||||
g.POST("/tag/delete", s.DeleteTag)
|
||||
}
|
||||
|
||||
// getTagList godoc
|
||||
// GetTagList godoc
|
||||
//
|
||||
// @Summary Get a list of tags
|
||||
// @Tags tag
|
||||
@@ -44,7 +44,7 @@ func (s *APIV1Service) registerTagRoutes(g *echo.Group) {
|
||||
// @Failure 500 {object} nil "Failed to find tag list"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/tag [GET]
|
||||
func (s *APIV1Service) getTagList(c echo.Context) error {
|
||||
func (s *APIV1Service) GetTagList(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -65,7 +65,7 @@ func (s *APIV1Service) getTagList(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, tagNameList)
|
||||
}
|
||||
|
||||
// createTag godoc
|
||||
// CreateTag godoc
|
||||
//
|
||||
// @Summary Create a tag
|
||||
// @Tags tag
|
||||
@@ -78,7 +78,7 @@ func (s *APIV1Service) getTagList(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to upsert tag | Failed to create activity"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/tag [POST]
|
||||
func (s *APIV1Service) createTag(c echo.Context) error {
|
||||
func (s *APIV1Service) CreateTag(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -107,7 +107,7 @@ func (s *APIV1Service) createTag(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, tagMessage.Name)
|
||||
}
|
||||
|
||||
// deleteTag godoc
|
||||
// DeleteTag godoc
|
||||
//
|
||||
// @Summary Delete a tag
|
||||
// @Tags tag
|
||||
@@ -120,7 +120,7 @@ func (s *APIV1Service) createTag(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to delete tag name: %v"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/tag/delete [POST]
|
||||
func (s *APIV1Service) deleteTag(c echo.Context) error {
|
||||
func (s *APIV1Service) DeleteTag(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -145,7 +145,7 @@ func (s *APIV1Service) deleteTag(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// getTagSuggestion godoc
|
||||
// GetTagSuggestion godoc
|
||||
//
|
||||
// @Summary Get a list of tags suggested from other memos contents
|
||||
// @Tags tag
|
||||
@@ -155,7 +155,7 @@ func (s *APIV1Service) deleteTag(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find memo list | Failed to find tag list"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/tag/suggestion [GET]
|
||||
func (s *APIV1Service) getTagSuggestion(c echo.Context) error {
|
||||
func (s *APIV1Service) GetTagSuggestion(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
|
@@ -68,17 +68,17 @@ type UpdateUserRequest struct {
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerUserRoutes(g *echo.Group) {
|
||||
g.GET("/user", s.getUserList)
|
||||
g.POST("/user", s.createUser)
|
||||
g.GET("/user/me", s.getCurrentUser)
|
||||
g.GET("/user", s.GetUserList)
|
||||
g.POST("/user", s.CreateUser)
|
||||
g.GET("/user/me", s.GetCurrentUser)
|
||||
// NOTE: This should be moved to /api/v2/user/:username
|
||||
g.GET("/user/name/:username", s.getUserByUsername)
|
||||
g.GET("/user/:id", s.getUserByID)
|
||||
g.DELETE("/user/:id", s.deleteUser)
|
||||
g.PATCH("/user/:id", s.updateUser)
|
||||
g.GET("/user/name/:username", s.GetUserByUsername)
|
||||
g.GET("/user/:id", s.GetUserByID)
|
||||
g.PATCH("/user/:id", s.UpdateUser)
|
||||
g.DELETE("/user/:id", s.DeleteUser)
|
||||
}
|
||||
|
||||
// getUserList godoc
|
||||
// GetUserList godoc
|
||||
//
|
||||
// @Summary Get a list of users
|
||||
// @Tags user
|
||||
@@ -86,7 +86,7 @@ func (s *APIV1Service) registerUserRoutes(g *echo.Group) {
|
||||
// @Success 200 {object} []store.User "User list"
|
||||
// @Failure 500 {object} nil "Failed to fetch user list"
|
||||
// @Router /api/v1/user [GET]
|
||||
func (s *APIV1Service) getUserList(c echo.Context) error {
|
||||
func (s *APIV1Service) GetUserList(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
list, err := s.Store.ListUsers(ctx, &store.FindUser{})
|
||||
if err != nil {
|
||||
@@ -104,7 +104,7 @@ func (s *APIV1Service) getUserList(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, userMessageList)
|
||||
}
|
||||
|
||||
// createUser godoc
|
||||
// CreateUser godoc
|
||||
//
|
||||
// @Summary Create a user
|
||||
// @Tags user
|
||||
@@ -117,7 +117,7 @@ func (s *APIV1Service) getUserList(c echo.Context) error {
|
||||
// @Failure 403 {object} nil "Could not create host user"
|
||||
// @Failure 500 {object} nil "Failed to find user by id | Failed to generate password hash | Failed to create user | Failed to create activity"
|
||||
// @Router /api/v1/user [POST]
|
||||
func (s *APIV1Service) createUser(c echo.Context) error {
|
||||
func (s *APIV1Service) CreateUser(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -172,7 +172,7 @@ func (s *APIV1Service) createUser(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, userMessage)
|
||||
}
|
||||
|
||||
// getCurrentUser godoc
|
||||
// GetCurrentUser godoc
|
||||
//
|
||||
// @Summary Get current user
|
||||
// @Tags user
|
||||
@@ -182,7 +182,7 @@ func (s *APIV1Service) createUser(c echo.Context) error {
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to find userSettingList"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/user/me [GET]
|
||||
func (s *APIV1Service) getCurrentUser(c echo.Context) error {
|
||||
func (s *APIV1Service) GetCurrentUser(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -212,7 +212,7 @@ func (s *APIV1Service) getCurrentUser(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, userMessage)
|
||||
}
|
||||
|
||||
// getUserByUsername godoc
|
||||
// GetUserByUsername godoc
|
||||
//
|
||||
// @Summary Get user by username
|
||||
// @Tags user
|
||||
@@ -222,7 +222,7 @@ func (s *APIV1Service) getCurrentUser(c echo.Context) error {
|
||||
// @Failure 404 {object} nil "User not found"
|
||||
// @Failure 500 {object} nil "Failed to find user"
|
||||
// @Router /api/v1/user/name/{username} [GET]
|
||||
func (s *APIV1Service) getUserByUsername(c echo.Context) error {
|
||||
func (s *APIV1Service) GetUserByUsername(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
username := c.Param("username")
|
||||
user, err := s.Store.GetUser(ctx, &store.FindUser{Username: &username})
|
||||
@@ -240,7 +240,7 @@ func (s *APIV1Service) getUserByUsername(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, userMessage)
|
||||
}
|
||||
|
||||
// getUserByID godoc
|
||||
// GetUserByID godoc
|
||||
//
|
||||
// @Summary Get user by id
|
||||
// @Tags user
|
||||
@@ -251,7 +251,7 @@ func (s *APIV1Service) getUserByUsername(c echo.Context) error {
|
||||
// @Failure 404 {object} nil "User not found"
|
||||
// @Failure 500 {object} nil "Failed to find user"
|
||||
// @Router /api/v1/user/{id} [GET]
|
||||
func (s *APIV1Service) getUserByID(c echo.Context) error {
|
||||
func (s *APIV1Service) GetUserByID(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
id, err := util.ConvertStringToInt32(c.Param("id"))
|
||||
if err != nil {
|
||||
@@ -273,7 +273,7 @@ func (s *APIV1Service) getUserByID(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, userMessage)
|
||||
}
|
||||
|
||||
// deleteUser godoc
|
||||
// DeleteUser godoc
|
||||
//
|
||||
// @Summary Delete a user
|
||||
// @Tags user
|
||||
@@ -285,7 +285,7 @@ func (s *APIV1Service) getUserByID(c echo.Context) error {
|
||||
// @Failure 403 {object} nil "Unauthorized to delete user"
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to delete user"
|
||||
// @Router /api/v1/user/{id} [DELETE]
|
||||
func (s *APIV1Service) deleteUser(c echo.Context) error {
|
||||
func (s *APIV1Service) DeleteUser(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
currentUserID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
@@ -317,7 +317,7 @@ func (s *APIV1Service) deleteUser(c echo.Context) error {
|
||||
return c.JSON(http.StatusOK, true)
|
||||
}
|
||||
|
||||
// updateUser godoc
|
||||
// UpdateUser godoc
|
||||
//
|
||||
// @Summary Update a user
|
||||
// @Tags user
|
||||
@@ -330,7 +330,7 @@ func (s *APIV1Service) deleteUser(c echo.Context) error {
|
||||
// @Failure 403 {object} nil "Unauthorized to update user"
|
||||
// @Failure 500 {object} nil "Failed to find user | Failed to generate password hash | Failed to patch user | Failed to find userSettingList"
|
||||
// @Router /api/v1/user/{id} [PATCH]
|
||||
func (s *APIV1Service) updateUser(c echo.Context) error {
|
||||
func (s *APIV1Service) UpdateUser(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, err := util.ConvertStringToInt32(c.Param("id"))
|
||||
if err != nil {
|
||||
|
@@ -79,12 +79,12 @@ type UpsertUserSettingRequest struct {
|
||||
}
|
||||
|
||||
func (s *APIV1Service) registerUserSettingRoutes(g *echo.Group) {
|
||||
g.POST("/user/setting", s.createUserSetting)
|
||||
g.POST("/user/setting", s.UpsertUserSetting)
|
||||
}
|
||||
|
||||
// createUserSetting godoc
|
||||
// UpsertUserSetting godoc
|
||||
//
|
||||
// @Summary Create user setting
|
||||
// @Summary Upsert user setting
|
||||
// @Tags user-setting
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
@@ -95,7 +95,7 @@ func (s *APIV1Service) registerUserSettingRoutes(g *echo.Group) {
|
||||
// @Failure 500 {object} nil "Failed to upsert user setting"
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v1/user/setting [POST]
|
||||
func (s *APIV1Service) createUserSetting(c echo.Context) error {
|
||||
func (s *APIV1Service) UpsertUserSetting(c echo.Context) error {
|
||||
ctx := c.Request().Context()
|
||||
userID, ok := c.Get(auth.UserIDContextKey).(int32)
|
||||
if !ok {
|
||||
|
Reference in New Issue
Block a user