Documentation
¶
Index ¶
- Constants
- func AuthUserId(tokenString string) (uint64, error)
- func GetBearerToken(r *http.Request) (string, error)
- func GetSchema(db Database) *graphql.Schema
- func HandleTodoistCallback(db Database) http.Handler
- func HandleTodoistLogin(db Database) http.Handler
- func Login(db Database, username string, password string) (string, error)
- func ServeCreateUser(db Database) func(rest.ResponseWriter, *rest.Request)
- func ServeLogin(db Database) func(rest.ResponseWriter, *rest.Request)
- func ServeVerifyToken(db Database) func(rest.ResponseWriter, *rest.Request)
- func SyncTodoist(db Database, userId uint64, oauthToken string) error
- type AccessTokenResponse
- type Action
- type ActionKind
- type Database
- type DuetClaims
- type Interval
- type Task
- type TaskKind
- type TodoistItem
- type TodoistSync
- type User
Constants ¶
View Source
const UserIdKey string = "user_id"
Variables ¶
This section is empty.
Functions ¶
func AuthUserId ¶
func HandleTodoistCallback ¶
func HandleTodoistLogin ¶
func ServeCreateUser ¶
func ServeCreateUser(db Database) func(rest.ResponseWriter, *rest.Request)
func ServeLogin ¶
func ServeLogin(db Database) func(rest.ResponseWriter, *rest.Request)
func ServeVerifyToken ¶
func ServeVerifyToken(db Database) func(rest.ResponseWriter, *rest.Request)
Types ¶
type AccessTokenResponse ¶
type Action ¶
type Action struct { Id string `json:"id" gorm:"primary_key;type:uuid;default:uuid_generate_v4()"` Kind ActionKind `json:"kind" gorm:"not_null"` When *time.Time `json:"when" gorm:"not_null"` TaskId string `json:"task_id" gorm:"not_null;type:uuid"` }
type ActionKind ¶
type ActionKind int
const ( ActionProgress ActionKind = iota ActionDefer ActionDone )
type Database ¶
type Database interface { Close() error GetTask(taskId string, userId uint64, kind *TaskKind) (*Task, error) GetTasks(userId uint64, kind *TaskKind) ([]Task, error) AddTask(task *Task, userId uint64) error DeleteTask(taskId string, userId uint64) (bool, error) UpdateTask(taskId string, userId uint64, attrs map[string]interface{}) (*Task, error) CreateUser(username string, password string) (*User, error) GetUserById(id uint64) (*User, error) GetUserByUsername(username string) (*User, error) AddAction(action *Action, userId uint64) error DeleteAction(id string, userId uint64) error }
type DuetClaims ¶
type DuetClaims struct {
jwt.StandardClaims
}
func VerifyToken ¶
func VerifyToken(tokenString string) (*DuetClaims, error)
type Task ¶
type Task struct { // Common fields CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time Id string `json:"id" gorm:"primary_key;type:uuid;default:uuid_generate_v4()"` Kind TaskKind `json:"kind" gorm:"not_null"` Title string `json:"title" gorm:"not_null"` Done bool `json:"done" gorm:"not_null;default:false"` UserId uint64 `json:"user_id" gorm:"not_null"` Actions []Action `json:"actions" gorm:"ForeignKey:TaskId"` // Task Fields StartDate *time.Time `json:"start_date"` EndDate *time.Time `json:"end_date"` // Habit Fields Interval Interval `json:"interval"` Frequency int `json:"frequency"` }
type TodoistItem ¶
type TodoistSync ¶
type TodoistSync struct { SyncToken string `json:"sync_token"` Items []TodoistItem `json:"items"` }
Click to show internal directories.
Click to hide internal directories.