Documentation
¶
Index ¶
- Constants
- Variables
- func NewPlugin() plugin.Plugin
- func RegisterCommentRoutes(app *fiber.App, db database.Database, config *Config)
- func RegisterRoutes(app *fiber.App, db database.Database, config *Config)
- type Comment
- type CommentResource
- type CommentablePlugin
- func (p *CommentablePlugin) Dependencies() []string
- func (p *CommentablePlugin) GetOpenAPIResources() []plugin.OpenAPIResource
- func (p *CommentablePlugin) Handler() fiber.Handler
- func (p *CommentablePlugin) Initialize(config map[string]interface{}) error
- func (p *CommentablePlugin) MigrationDependencies() []string
- func (p *CommentablePlugin) MigrationSource() interface{}
- func (p *CommentablePlugin) Name() string
- func (p *CommentablePlugin) SetupEndpoints(app *fiber.App) error
- type Config
- type CreateCommentRequest
- type UpdateCommentRequest
Constants ¶
View Source
const ( StatusAwaiting = "awaiting" StatusPublished = "published" StatusDraft = "draft" StatusModerated = "moderated" )
View Source
const MaxFilterValuesPerField = 50
Variables ¶
View Source
var ValidStatuses = []string{ StatusAwaiting, StatusPublished, StatusDraft, StatusModerated, }
Functions ¶
func RegisterCommentRoutes ¶
Types ¶
type Comment ¶
type Comment struct {
Id string `json:"id,omitempty" db:"id" rbac:"read:*;write:none"`
UserId *string `json:"userId,omitempty" db:"user_id" rbac:"read:*;write:reader"`
CommentableId string `json:"commentableId" db:"commentable_id" rbac:"read:*;write:reader"`
Commentable string `json:"commentable" db:"commentable" rbac:"read:*;write:reader"`
ParentId *string `json:"parentId,omitempty" db:"parent_id" rbac:"read:*;write:reader"`
Content string `json:"content" db:"content" rbac:"read:*;write:reader"`
Status string `json:"status" db:"status" rbac:"read:*;write:moderator"`
IpAddress *string `json:"ipAddress,omitempty" db:"ip_address" rbac:"read:moderator;write:none"`
UserAgent *string `json:"userAgent,omitempty" db:"user_agent" rbac:"read:moderator;write:none"`
UpdatedAt *time.Time `json:"updatedAt,omitempty" db:"updated_at" rbac:"read:*;write:none"`
CreatedAt *time.Time `json:"createdAt,omitempty" db:"created_at" rbac:"read:*;write:none"`
}
type CommentResource ¶
type CommentablePlugin ¶
type CommentablePlugin struct {
// contains filtered or unexported fields
}
func (*CommentablePlugin) Dependencies ¶ added in v0.1.1
func (p *CommentablePlugin) Dependencies() []string
func (*CommentablePlugin) GetOpenAPIResources ¶ added in v0.1.3
func (p *CommentablePlugin) GetOpenAPIResources() []plugin.OpenAPIResource
func (*CommentablePlugin) Handler ¶
func (p *CommentablePlugin) Handler() fiber.Handler
func (*CommentablePlugin) Initialize ¶
func (p *CommentablePlugin) Initialize(config map[string]interface{}) error
func (*CommentablePlugin) MigrationDependencies ¶
func (p *CommentablePlugin) MigrationDependencies() []string
func (*CommentablePlugin) MigrationSource ¶
func (p *CommentablePlugin) MigrationSource() interface{}
func (*CommentablePlugin) Name ¶
func (p *CommentablePlugin) Name() string
func (*CommentablePlugin) SetupEndpoints ¶
func (p *CommentablePlugin) SetupEndpoints(app *fiber.App) error
type Config ¶
type Config struct {
Database database.Database
AllowedTypes []string `json:"allowed_types" yaml:"allowed_types"`
MaxContentLength int `json:"max_content_length" yaml:"max_content_length"`
PaginationLimit int `json:"pagination_limit" yaml:"pagination_limit"`
MaxPaginationLimit int `json:"max_pagination_limit" yaml:"max_pagination_limit"`
EnableNesting bool `json:"enable_nesting" yaml:"enable_nesting"`
MaxNestingDepth int `json:"max_nesting_depth" yaml:"max_nesting_depth"`
DefaultStatus string `json:"default_status" yaml:"default_status"`
}
func DefaultConfig ¶
func DefaultConfig() Config
func (*Config) IsAllowedType ¶
type CreateCommentRequest ¶
type CreateCommentRequest struct {
CommentableId string `json:"commentableId" validate:"required,uuid"`
Commentable string `json:"commentable" validate:"required"`
ParentId *string `json:"parentId,omitempty" validate:"omitempty,uuid"`
Content string `json:"content" validate:"required"`
}
func (*CreateCommentRequest) Validate ¶
func (r *CreateCommentRequest) Validate(config *Config) error
type UpdateCommentRequest ¶
type UpdateCommentRequest struct {
Content *string `json:"content,omitempty"`
Status *string `json:"status,omitempty"`
}
func (*UpdateCommentRequest) Validate ¶
func (r *UpdateCommentRequest) Validate(config *Config) error
Click to show internal directories.
Click to hide internal directories.