Documentation ¶
Index ¶
- Constants
- Variables
- func NewOptionalString(s string) *string
- func NewOptionalTime() *time.Time
- func NewRandomAttachmentsURLArray(num int) []string
- type CreatePostInput
- type ForgotPasswordInput
- type Node
- type PageInfo
- type Post
- type PostConnection
- type PostEdge
- type Session
- type SessionConnection
- type SessionCredInput
- type SessionEdge
- type SignInInput
- type SignUpInput
- type SortOptions
- type Tokens
- type UpdatePostInput
- type UploadFile
- type User
Constants ¶
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.
const ( CodeServerError string = "SERVER_ERROR" CodeInternalServerError string = "INTERNAL_SERVER_ERROR" CodeInvalidArgument string = "INVALID_ARGUMENT" CodeNotFound string = "NOT_FOUND" CodeAlreadyExists string = "ALREADY_EXISTS" )
GraphQL error status codes.
const UserCtx string = "userId"
Variables ¶
var ( RxUsername = regexp.MustCompile(Username) RxPassword = regexp.MustCompile(Password) RxEmail = regexp.MustCompile(Email) )
Functions ¶
func NewOptionalString ¶
Creating a new random optional string.
func NewRandomAttachmentsURLArray ¶
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 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.
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.
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.
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.
type SortOptions ¶
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.