domain

package
v0.0.0-...-e331df4 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Username string = "^[a-zA-Z0-9-_.]{3,40}$"
	Password string = "^[a-zA-Z0-9@$!%*?&]{8,100}$"
	Email    string = "" /* 454-byte string literal not displayed */
)

Regular fot validating strings.

View Source
const (
	CodeServerError         string = "SERVER_ERROR"
	CodeInternalServerError string = "INTERNAL_SERVER_ERROR"
	CodeInvalidArgument     string = "INVALID_ARGUMENT"
	CodeNotFound            string = "NOT_FOUND"
	CodeAlreadyExists       string = "ALREADY_EXISTS"
	CodeUnauthorized        string = "UNAUTHORIZED"
)

GraphQL error status codes.

View Source
const UserCtx string = "userId"

Variables

View Source
var (
	RxUsername = regexp.MustCompile(Username)
	RxPassword = regexp.MustCompile(Password)
	RxEmail    = regexp.MustCompile(Email)
)

Functions

func NewOptionalString

func NewOptionalString(s string) *string

Creating a new random optional string.

func NewOptionalTime

func NewOptionalTime() *time.Time

Creating a new random optional time.

func NewRandomAttachmentsURLArray

func NewRandomAttachmentsURLArray(num int) []string

Creating a new random optional array of attachments url.

Types

type CreatePostInput

type CreatePostInput struct {
	// Post text.
	Text string `json:"text"`
	// Post attachments.
	Attachments []*UploadFile `json:"attachments"`
}

Create post input.

func (CreatePostInput) Validate

func (i CreatePostInput) Validate() error

Validate create post input.

type ForgotPasswordInput

type ForgotPasswordInput struct {
	// User email.
	Email string `json:"email"`
	// New user password.
	Password string `json:"password"`
	// User verification code.
	Code uint64 `json:"code"`
}

Forgot user password input.

func (ForgotPasswordInput) Validate

func (i ForgotPasswordInput) Validate() error

Validate user forgot password input.

type Node

type Node interface {
	IsNode()
}

GraphQL Node interface.

type PageInfo

type PageInfo struct {
	// When paginating backwards, the cursor to continue.
	StartCursor *string `json:"startCursor"`
	// When paginating forwards, the cursor to continue.
	EndCursor *string `json:"endCursor"`
}

Information about pagination in a connection.

type Post

type Post struct {
	// Post id.
	Id ksuid.KSUID `json:"id"`
	// Post author.
	Author *User `json:"author"`
	// Post text.
	Text string `json:"text"`
	// Post updated date.
	UpdatedAt *time.Time `json:"updatedAt"`
	// Post attachments.
	Attachments []string `json:"attachments"`
}

Post type.

func NewPost

func NewPost(id ksuid.KSUID) *Post

Creating a new post.

func (Post) IsNode

func (Post) IsNode()

type PostConnection

type PostConnection struct {
	// A list of nodes.
	Nodes []*Post `json:"nodes"`
	// Identifies the total count of items in the connection.
	TotalCount int `json:"totalCount"`
}

List of post owned by the subject.

type PostEdge

type PostEdge struct {
	// A cursor for use in pagination.
	Cursor string `json:"cursor"`
	// The item at the end of the edge.
	Node *Post `json:"node"`
}

An edge in a post connection.

type Session

type Session struct {
	// Session id.
	Id ksuid.KSUID `json:"id"`
	// Session user id.
	UserId ksuid.KSUID `json:"userId"`
	// User session ip address.
	Ip string `json:"ip"`
	// Session expires in.
	ExpiresIn time.Time `json:"expiresIn"`
}

User session.

func NewSession

func NewSession(id ksuid.KSUID) *Session

Creating a new user session.

func (Session) IsNode

func (Session) IsNode()

type SessionConnection

type SessionConnection struct {
	// A list of nodes.
	Nodes []*Session `json:"nodes"`
	// Identifies the total count of items in the connection.
	TotalCount int `json:"totalCount"`
}

List of session owned by the subject.

type SessionCredInput

type SessionCredInput struct {
	// Refresh token.
	Refresh string `json:"refresh"`
	// Client secret key.
	Secret string `json:"secret"`
}

Session credentials input.

type SessionEdge

type SessionEdge struct {
	// A cursor for use in pagination.
	Cursor string `json:"cursor"`
	// The item at the end of the edge.
	Node *Session `json:"node"`
}

An edge in a session connection.

type SignInInput

type SignInInput struct {
	// Account login.
	Login string `json:"login"`
	// User password
	Password string `json:"password"`
	// Client secret key.
	Secret string `json:"secret"`
}

User Sign In input.

func (SignInInput) Validate

func (i SignInInput) Validate() error

Validate user sign in input.

type SignUpInput

type SignUpInput struct {
	// Account username.
	Username string `json:"username"`
	// User email.
	Email string `json:"email"`
	// User password.
	Password string `json:"password"`
	// User verification code.
	Code uint64 `json:"code"`
	// Client secret key.
	Secret string `json:"secret"`
}

User Sign Up input.

func (SignUpInput) Validate

func (i SignUpInput) Validate() error

Validate user sign up input.

type SortOptions

type SortOptions struct {
	First  *int
	Last   *int
	Before *string
	After  *string
}

Query sorting options.

func (SortOptions) Validate

func (o SortOptions) Validate() (int, error)

Validating query sort options.

type Tokens

type Tokens struct {
	// JWT access token.
	Access string `json:"access"`
	// Refresh token.
	Refresh string `json:"refresh"`
}

Authorization tokens.

type UpdatePostInput

type UpdatePostInput struct {
	// Post id.
	Id ksuid.KSUID `json:"id"`
	// Post text.
	Text string `json:"text"`
}

Update post input.

func (UpdatePostInput) Validate

func (i UpdatePostInput) Validate() error

Validate update post input.

type UploadFile

type UploadFile struct {
	// File id.
	Id int `json:"id"`
	// File data.
	File graphql.Upload `json:"file"`
}

Upload files input.

type User

type User struct {
	// User id.
	Id ksuid.KSUID `json:"id"`
	// Username.
	Username string `json:"username"`
	// User last visit date.
	LastVisit time.Time `json:"lastVisit"`
	// User verified status.
	Verified bool `json:"verified"`
	// User avatar url.
	AvatarUrl *string `json:"avatarUrl"`
}

User type.

func NewUser

func NewUser(id ksuid.KSUID) *User

Creating a new user.

func (User) IsNode

func (User) IsNode()

Jump to

Keyboard shortcuts

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