api

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package api defines the HTTP request and response types for the backend REST API.

These types serve as the shared contract between the backend (which serializes them) and the frontend apiclient (which deserializes them). All types are JSON-encoded.

Design rules

A type belongs here only if it adds value over the domain types in shared/domain:

  • Request DTOs always belong here — they carry JSON tags, validation rules, and field shapes that differ from domain creation types.

  • Response types belong here when they combine or reshape domain data: BoardListResponse wraps a slice (JSON requires an object, not a bare array), LoginResponse adds an access token, CreateMessageResponse pairs an ID with its page number, BlacklistResponse and InviteListResponse add pagination.

  • Pure domain wrappers that add no fields are omitted — the handler returns the domain type directly, and the apiclient decodes into it directly.

Cross-cutting concern

Because both services compile against shared/domain, this package does not provide a versioning boundary between them. If the services were ever split into independently deployed binaries with external clients, response wrappers should be reintroduced to decouple the API contract from internal domain evolution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlacklistResponse

type BlacklistResponse struct {
	Users []domain.BlacklistEntry `json:"users"`
	Page  int                     `json:"page"`
}

type BlacklistUserRequest

type BlacklistUserRequest struct {
	Reason string `json:"reason"`
}

type BoardListResponse

type BoardListResponse struct {
	Boards []domain.BoardMetadata `json:"boards"`
}

BoardListResponse wraps a list of boards

type CheckConfirmationCodeRequest

type CheckConfirmationCodeRequest struct {
	Email            string `json:"email" validate:"required,email"`
	ConfirmationCode string `json:"confirmation_code" validate:"required"`
}

type CreateBoardRequest

type CreateBoardRequest struct {
	Name          string         `json:"name" validate:"required"`
	ShortName     string         `json:"short_name" validate:"required"`
	AllowedEmails *domain.Emails `json:"allowed_emails,omitempty"`
}

type CreateMessageRequest

type CreateMessageRequest struct {
	Text            string              `json:"text,omitempty"`
	ShowEmailDomain bool                `json:"show_email_domain,omitempty"`
	Attachments     *domain.Attachments `json:"attachments,omitempty"`
	ReplyTo         *domain.Replies     `json:"reply_to,omitempty"`
}

type CreateMessageResponse

type CreateMessageResponse struct {
	Id   int64 `json:"id"`
	Page int   `json:"page"` // Page number where the message appears
}

CreateMessageResponse returns the ID of the created message and its page

type CreateThreadRequest

type CreateThreadRequest struct {
	Title     string               `json:"title" validate:"required"`
	IsPinned  bool                 `json:"is_pinned,omitempty"`
	OpMessage CreateMessageRequest `json:"op_message"`
}

type InviteListResponse added in v0.1.1

type InviteListResponse struct {
	Invites []domain.InviteCode `json:"invites"`
	Page    int                 `json:"page"`
}

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email" validate:"required,email"`
	Password string `json:"password" validate:"required"`
}

type LoginResponse

type LoginResponse struct {
	Message     string `json:"message"`
	AccessToken string `json:"access_token,omitempty"` // Token for non-cookie clients (mobile, API clients)
}

type RegisterRequest

type RegisterRequest struct {
	Email    string `json:"email" validate:"required,email"`
	Password string `json:"password" validate:"required"`
}

type UserActivityResponse

type UserActivityResponse struct {
	Messages []domain.Message `json:"messages"`
}

UserActivityResponse contains user's recent messages Messages are FULLY enriched (Author, Attachments, Replies)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL