package module
Version: v0.0.0-...-19fadcf Latest Latest

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

Go to latest
Published: Feb 28, 2021 License: MIT Imports: 33 Imported by: 0


Run Server

go run cmd/wonderwall/main

Run App

go run wonder/main

Web build

Install js dependencies

npm install

build js assets

webpack --env.NODE_ENV=local --progress

webpack --env.NODE_ENV=dev --env.production=false --progress






This section is empty.


View Source
var (
	EmailErr    = errors.New("invalid email")
	PasswordErr = errors.New("invalid password")
View Source
var DuplicateEmailErr = errors.New("duplicate email")
View Source
var ErrScheduleTimeout = fmt.Errorf("schedule error: timed out")
View Source
var (
	ErrWallTitleEmpty = errors.New("wall title empty")


func ContentType

func ContentType(t string, w http.ResponseWriter, r *http.Request) bool

func DeleteWallHandler

func DeleteWallHandler(db *Store, security Auth, walls *Walls) http.HandlerFunc

func Deserialize

func Deserialize(v []byte, e interface{}) error

func GetWallHandler

func GetWallHandler(db *Store, security Auth, walls *Walls) http.HandlerFunc

func LoadTestUser

func LoadTestUser(db *Store, users CreateUser)

func Logout

func Logout(sessionManager *scs.SessionManager) http.HandlerFunc

func PatchWallHandler

func PatchWallHandler(security Auth) http.HandlerFunc

func PostForgotPassword

func PostForgotPassword(db *Store, users FindUserByEmail) http.HandlerFunc

func PostLogin

func PostLogin(db *Store, users FindUserByEmail, registrations FindRegistrationByEmail, sessionManager *scs.SessionManager, emails SendEmail) http.HandlerFunc

func PostRegistration

func PostRegistration(db *Store, registrations CreateRegistration, users FindUserByEmail, emails SendEmail) http.HandlerFunc

func PostResetPassword

func PostResetPassword(db *Store, users FindUserByEmail) http.HandlerFunc

func PostVerifyEmail

func PostVerifyEmail(db *Store, registrations FindRegistrationByID, users CreateUser) http.HandlerFunc

func PostWallHandler

func PostWallHandler(db *Store, security Auth, walls *Walls) http.HandlerFunc

func RebuildSearchIndex

func RebuildSearchIndex()

func RenderTemplate

func RenderTemplate(name string) http.HandlerFunc

func Serialize

func Serialize(e interface{}) ([]byte, error)

func StartServer

func StartServer()

func WallCollab

func WallCollab(conf CollabConfig, db *Store, walls interface {
}) http.HandlerFunc

func WallMapping

func WallMapping(index *mapping.IndexMappingImpl)


type Action

type Action struct {
	Action   string `json:"action"`
	Node     Node   `json:"node"`
	Original *Node  `json:"original"`

func ReadAction

func ReadAction(r io.Reader) (*Action, error)

func (Action) Add

func (a Action) Add(s State)

func (Action) Apply

func (a Action) Apply(s State)

func (Action) Remove

func (a Action) Remove(s State)

func (Action) Update

func (a Action) Update(s State)

type CollabConfig

type CollabConfig struct {
	Debug     bool
	Workers   int
	Queue     int
	IOTimeout time.Duration

type Collaborator

type Collaborator struct {
	// contains filtered or unexported fields

func (*Collaborator) Receive

func (u *Collaborator) Receive() error

Receive reads next message from user's underlying connection. It blocks until full message received.

type Collective

type Collective struct {
	// contains filtered or unexported fields

Chat contains logic of user interaction.

func NewChat

func NewChat(pool *Pool) *Collective

func (*Collective) Broadcast

func (c *Collective) Broadcast(method string, params Object) error

Broadcast sends message to all alive users.

func (*Collective) Register

func (c *Collective) Register(conn net.Conn) *Collaborator

Register registers new connection as a User.

func (*Collective) Remove

func (c *Collective) Remove(user *Collaborator)

Remove removes user from chat.

func (*Collective) Rename

func (c *Collective) Rename(user *Collaborator, name string) (prev string, ok bool)

Rename renames user.

type Config

type Config struct {
	Debug  bool
	Store  StoreConfig
	Server ServerConfig
	Email  EmailConfig

func ReadConfig

func ReadConfig(r io.Reader) (*Config, error)

type CreateRegistration

type CreateRegistration interface {
	CreateRegistration(*Txn, Email, Password) (*Registration, error)

type CreateSession

type CreateSession interface {
	CreateSession(*Txn, string) (*Session, error)

type CreateUser

type CreateUser interface{ CreateUser(*Txn, *User) error }

type CreateWall

type CreateWall interface {
	CreateWall(*Txn, string, Key) (*Wall, error)

type DeleteUser

type DeleteUser interface{ DeleteUser(*Txn, *User) error }

type DeleteWall

type DeleteWall interface{ DeleteWall(*Txn, *Wall) error }

type Email

type Email string

func (Email) String

func (e Email) String() string

func (Email) Valid

func (e Email) Valid() bool

type EmailClient

type EmailClient struct {
	Conf      EmailConfig
	SendMail  SendMailFunc
	Templates map[string]template.Template

func (EmailClient) SendEmail

func (s EmailClient) SendEmail(name string, to Email, i interface{}) error

type EmailConfig

type EmailConfig struct {
	SenderAddr string
	Username   string
	Password   string
	ServerHost string
	ServerPort string
	Origin     string

type EmailForm

type EmailForm struct{ Email Email }

type Error

type Error struct {
	ID    int    `json:"id"`
	Error Object `json:"error"`

type ErrorResult

type ErrorResult struct {
	Message string

type FindRegistrationByEmail

type FindRegistrationByEmail interface {
	FindRegistrationByEmail(*Txn, Email) (*Registration, error)

type FindRegistrationByID

type FindRegistrationByID interface {
	FindRegistrationByID(*Txn, Token) (*Registration, error)

type FindUserByEmail

type FindUserByEmail interface {
	FindUserByEmail(*Txn, Email) (*User, error)

type FindUserById

type FindUserById interface {
	FindUserById(*Txn, xid.ID) (*User, error)

type FindWallById

type FindWallById interface {
	FindWallById(*Txn, xid.ID) (*Wall, error)

type ForgotPasswordForm

type ForgotPasswordForm struct {
	Email Email `json:"email"`

type Index

type Index struct{ Primary, Secondary Key }

type JsonResult

type JsonResult struct{}

type Key

type Key []byte

func (*Key) Deserialize

func (k *Key) Deserialize(b []byte) error

func (Key) Eq

func (k Key) Eq(other Key) bool

type LogConfig

type LogConfig struct {

type LoginForm

type LoginForm struct {
	Email    Email    `json:"email"`
	Password Password `json:"password"`

type Node

type Node struct {
	ID        string
	ClassName string                 `json:"className"`
	Attrs     map[string]interface{} `json:"attrs"`

type Object

type Object map[string]interface{}

type Password

type Password string

func (Password) HashPassword

func (p Password) HashPassword() (PasswordHash, error)

func (Password) Valid

func (p Password) Valid() bool

type PasswordForm

type PasswordForm struct {
	Password Password

type PasswordHash

type PasswordHash []byte

func (PasswordHash) ComparePassword

func (h PasswordHash) ComparePassword(p Password) error

type Pool

type Pool struct {
	// contains filtered or unexported fields

func NewPool

func NewPool(size, queue, spawn int) *Pool

NewPool creates new goroutine pool with given size. It also creates a work queue of given size. Finally, it spawns given amount of goroutines immediately. Make pool of X size, Y sized work queue and one pre-spawned goroutine.

func (*Pool) Schedule

func (p *Pool) Schedule(task func())

Schedule schedules task to be executed over pool's workers.

func (*Pool) ScheduleTimeout

func (p *Pool) ScheduleTimeout(timeout time.Duration, task func()) error

ScheduleTimeout schedules task to be executed over pool's workers. It returns ErrScheduleTimeout when no free workers met during given timeout.

type RawResult

type RawResult struct{}

type Readable

type Readable interface{ Deserialize([]byte) error }

type Registration

type Registration struct {
	ID           Token
	Email        Email
	PasswordHash PasswordHash
	CreatedAt    time.Time
	VerifiedAt   *time.Time

func (*Registration) Deserialize

func (r *Registration) Deserialize(b []byte) error

func (*Registration) Key

func (r *Registration) Key() Key

func (*Registration) Serialize

func (r *Registration) Serialize() ([]byte, error)

type RegistrationForm

type RegistrationForm struct {
	Email    Email    `json:"email"`
	Password Password `json:"password"`

func (RegistrationForm) Validate

func (f RegistrationForm) Validate() error

type RegistrationService

type RegistrationService interface {

type Registrations

type Registrations struct{ DB *Store }

func (Registrations) CreateRegistration

func (s Registrations) CreateRegistration(txn *Txn, email Email, password Password) (*Registration, error)

func (Registrations) FindRegistrationByEmail

func (s Registrations) FindRegistrationByEmail(*Txn, Email) (*Registration, error)

func (Registrations) FindRegistrationByID

func (s Registrations) FindRegistrationByID(*Txn, Token) (*Registration, error)

type Request

type Request struct {
	ID     int    `json:"id"`
	Method string `json:"method"`
	Params Object `json:"params"`

type Response

type Response struct {
	ID     int    `json:"id"`
	Result Object `json:"result"`

type Result

type Result interface {
	MarshalJSON() ([]byte, error)
	ContentType() string

type Result2

type Result2 struct {
	Result   []interface{}
	Previous *string
	Next     *string
	Error    error `json:"error"`

type SendEmail

type SendEmail interface {
	SendEmail(name string, email Email, i interface{}) error

func NewEmailClient

func NewEmailClient(from, addr, username, password, origin string) SendEmail

func NewEmailPrinter

func NewEmailPrinter(origin string) SendEmail

type SendMailFunc

type SendMailFunc func(string, smtp.Auth, string, []string, []byte) error

type ServerConfig

type ServerConfig struct {
	Addr string

type Session

type Session struct {
	ID        Token
	UserID    string
	CreatedAt time.Time

type Sessions

type Sessions struct{}

func (Sessions) CreateSession

func (s Sessions) CreateSession(*Txn, string) (*Session, error)

type State

type State struct {
	Image *[]Node `json:"image"`
	Text  *[]Node `json:"text"`
	Pen   *[]Node `json:"pen"`

func (State) Layer

func (s State) Layer(n string) *[]Node

type Store

type Store struct {
	Index bleve.Index

func NewStore

func NewStore(conf StoreConfig) (*Store, error)

func (*Store) Delete

func (s *Store) Delete(tx *Txn, k []byte) error

func (*Store) Get

func (s *Store) Get(tx *Txn, k Key, r Readable) error

func (*Store) Keys

func (s *Store) Keys(txn *Txn, k Key, keys *[]Key) error

func (*Store) Set

func (s *Store) Set(txn *Txn, o Writable) error

type StoreConfig

type StoreConfig struct {
	Path       string
	InMemoryDB bool

type Token

type Token []byte

func GenerateToken

func GenerateToken(n int) (Token, error)

type Txn

type Txn = badger.Txn

type UpdateWall

type UpdateWall interface{ UpdateWall(*Txn, *Wall) error }

type User

type User struct {
	ID           xid.ID
	Email        Email
	PasswordHash PasswordHash
	Name         string
	Roles        []Role

func (*User) Deserialize

func (u *User) Deserialize(b []byte) error

func (*User) EmailKey

func (u *User) EmailKey() Key

func (*User) Eq

func (u *User) Eq(other *User) bool

func (*User) Key

func (u *User) Key() Key

func (*User) Serialize

func (u *User) Serialize() ([]byte, error)

type UserService

type UserService interface {

type Users

type Users struct {
	DB *Store

func (Users) CreateUser

func (s Users) CreateUser(txn *Txn, u *User) error

func (Users) DeleteUser

func (s Users) DeleteUser(txn *Txn, u *User) error

func (Users) FindUserByEmail

func (s Users) FindUserByEmail(txn *Txn, email Email) (*User, error)

func (Users) FindUserById

func (s Users) FindUserById(txn *Txn, id xid.ID) (*User, error)

type Verification

type Verification struct{ Token Token }

type Wall

type Wall struct {
	ID         xid.ID        `json:"id"`
	Title      string        `json:"title"`
	Owner      Key           `json:"owner"`
	CreatedAt  time.Time     `json:"createdAt"`
	ModifiedAt time.Time     `json:"modifiedAt"`
	AllowList  []Key         `json:"allowList"`
	Content    []interface{} `json:"content"`

func (*Wall) Deserialize

func (w *Wall) Deserialize(b []byte) error

func (*Wall) Key

func (w *Wall) Key() Key

func (*Wall) Serialize

func (w *Wall) Serialize() ([]byte, error)

func (Wall) Validate

func (w Wall) Validate() error

type Walls

type Walls struct {
	DB *Store

func (Walls) CreateWall

func (s Walls) CreateWall(txn *Txn, title string, owner Key) (*Wall, error)

func (Walls) DeleteWall

func (s Walls) DeleteWall(txn *Txn, w *Wall) error

func (Walls) FindWallById

func (s Walls) FindWallById(txn *Txn, id xid.ID) (*Wall, error)

func (Walls) SearchWalls

func (s Walls) SearchWalls() error

func (Walls) UpdateWall

func (s Walls) UpdateWall(txn *Txn, w *Wall) error

type Writable

type Writable interface {
	Serialize() ([]byte, error)
	Key() Key


Path Synopsis
colorpicker module
wonder module

Jump to

Keyboard shortcuts

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