model

package
v0.0.0-...-6f95374 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSessionExpiresIn = time.Hour * 24 * 30
	SessionKeyFormat        = "%s:%s"
)
View Source
const DefaultArticleSize = value.Size(20)
View Source
const DefaultAuthExpiresIn = time.Hour // 1 hour
View Source
const DefaultCodeExpiresIn = 10 * time.Minute // 10 minutes

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	ArticleID   article.ID          // ID
	URL         article.URL         // 記事のURL
	Title       article.Title       // タイトル
	Description article.Description // 記事の説明
	Thumbnail   article.Thumbnail   // サムネイル
	TagList     article.TagList     // タグリスト
}

Article 記事モデル.

func CreateArticle

func CreateArticle(
	url article.URL,
	title article.Title,
	description article.Description,
	thumbnail article.Thumbnail,
	tags article.TagList,
) Article

CreateArticle 記事モデルを新規作成する関数.

func NewArticle

func NewArticle(
	id article.ID,
	url article.URL,
	title article.Title,
	description article.Description,
	thumbnail article.Thumbnail,
	tags article.TagList,
) (Article, error)

NewArticle 記事モデルのファクトリー関数.

func ReconstructArticle

func ReconstructArticle(
	id uuid.UUID,
	url string,
	title string,
	description string,
	thumbnail string,
	tags []string,
) Article

ReconstructArticle 記事モデルの再構築関数.

type Auth

type Auth struct {
	AuthID    user.ID   `json:"authId"`
	UserID    user.ID   `json:"userId"`
	IssuedAt  time.Time `json:"issuedAt"`
	ExpiresAt time.Time `json:"expiresAt"`
}

func IssueAuth

func IssueAuth(
	userID user.ID,
	expiresIn auth.ExpiresIn,
) Auth

func NewAuth

func NewAuth(
	authID user.ID,
	userID user.ID,
	issuedAt time.Time,
	expiresAt time.Time,
) (Auth, error)

func (Auth) ExpiresIn

func (at Auth) ExpiresIn() auth.ExpiresIn

func (Auth) IsExpired

func (at Auth) IsExpired() bool

func (Auth) ToToken

func (at Auth) ToToken(
	secret auth.Secret,
) auth.AuthToken

type Code

type Code struct {
	CodeID    auth.CodeID    `json:"codeId"`
	SessionID auth.SessionID `json:"sessionId"`
	IssuedAt  time.Time      `json:"issuedAt"`
	ExpiresAt time.Time      `json:"expiresAt"`
}

func GenerateCode

func GenerateCode(
	sessionID auth.SessionID,
) Code

func NewCode

func NewCode(
	codeID auth.CodeID,
	sessionID auth.SessionID,
	issuedAt time.Time,
	expiresAt time.Time,
) (Code, error)

func (Code) IsExpired

func (cd Code) IsExpired() bool

type Invitation

type Invitation struct {
	Code  auth.InvitationCode
	Email auth.Email
}

func GenerateInvitation

func GenerateInvitation(
	email auth.Email,
) Invitation

func NewInvitation

func NewInvitation(
	code auth.InvitationCode,
	email auth.Email,
) (Invitation, error)

func (Invitation) Message

func (inv Invitation) Message() notice.Message

func (Invitation) Subject

func (inv Invitation) Subject() notice.Subject

type Session

type Session struct {
	SessionID auth.SessionID `json:"sessionId"`
	UserID    user.ID        `json:"userId"`
	PublicKey rsa.PublicKey  `json:"publicKey"`
	IssuedAt  time.Time      `json:"issuedAt"`
	ExpiresAt time.Time      `json:"expiresAt"`
}

func IssueSession

func IssueSession(
	userID user.ID,
	publicKey rsa.PublicKey,
) Session

func NewSession

func NewSession(
	sessionID auth.SessionID,
	userID user.ID,
	publicKey rsa.PublicKey,
	issuedAt time.Time,
	expiresAt time.Time,
) (Session, error)

func (Session) IsExpired

func (sss Session) IsExpired() bool

func (Session) Key

func (sss Session) Key() string

func (Session) ToToken

func (sss Session) ToToken(
	secret auth.Secret,
) auth.SessionToken

type User

type User struct {
	UserID user.ID
}

func CreateUser

func CreateUser() User

func NewUser

func NewUser(
	userID user.ID,
) User

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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