task

package module
v0.0.0-...-b45dc3e Latest Latest
Warning

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

Go to latest
Published: May 20, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingField = errors.New("missing field is required")
View Source
var ErrTaskNotFound = errors.New("task not found")

Functions

func NewHTTPHandler

func NewHTTPHandler(service Service, middlewares ...func(http.Handler) http.Handler) http.Handler

func NewMongoClient

func NewMongoClient(uri string, timeout int64) (*mongo.Client, error)

func NewRepository

func NewRepository(client *mongo.Client, dbname string) *repository

func NewService

func NewService(repository Repository) *service

Types

type ContextKey

type ContextKey string
var UserIDCtxKey ContextKey = ContextKey("userId")

type Middleware

type Middleware struct {
	AuthEndpoint string
}

func (*Middleware) Authenticate

func (m *Middleware) Authenticate(next http.Handler) http.Handler

type NewTask

type NewTask struct {
	UserID    string     `json:"userId,omitempty"`
	Name      string     `json:"name"`
	Details   string     `json:"details,omitempty"`
	Priority  string     `json:"priority,omitempty"`
	Category  string     `json:"category,omitempty"`
	CreatedAt *time.Time `json:"createdAt,omitempty"`
	UpdatedAt *time.Time `json:"updatedAt,omitempty"`
}

type NewTaskDocument

type NewTaskDocument struct {
	UserID    primitive.ObjectID `bson:"userId,omitempty"`
	Name      string             `bson:"name"`
	Details   string             `bson:"details,omitempty"`
	Priority  string             `bson:"priority,omitempty"`
	Category  string             `bson:"category,omitempty"`
	CreatedAt *time.Time         `bson:"createdAt,omitempty"`
	UpdatedAt *time.Time         `bson:"updatedAt,omitempty"`
}

NewTaskDocument is an intermediary data type that is used by a repository layer that impements mongo to communicate with the mongodb driver API.

type Repository

type Repository interface {
	// contains filtered or unexported methods
}

type Server

type Server struct {
	Port    string
	Handler http.Handler
}

func (Server) Run

func (s Server) Run() error

type Service

type Service interface {
	// contains filtered or unexported methods
}

type Task

type Task struct {
	ID        string     `json:"taskId,omitempty"`
	UserID    string     `json:"userId,omitempty"`
	Name      string     `json:"name"`
	Details   string     `json:"details,omitempty"`
	Priority  string     `json:"priority,omitempty"`
	Category  string     `json:"category,omitempty"`
	CreatedAt *time.Time `json:"createdAt,omitempty"`
	UpdatedAt *time.Time `json:"updatedAt,omitempty"`
}

type TaskDocument

type TaskDocument struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	UserID    primitive.ObjectID `bson:"userId,omitempty"`
	Name      string             `bson:"name,omitempty"`
	Details   string             `bson:"details,omitempty"`
	Priority  string             `bson:"priority,omitempty"`
	Category  string             `bson:"category,omitempty"`
	CreatedAt *time.Time         `bson:"createdAt,omitempty"`
	UpdatedAt *time.Time         `bson:"updatedAt,omitempty"`
}

TaskDocument is a data type used by a repository layer that implements mongo to communicate with the mongo API. The 'omitempty' tag is used to prevent an empty field value from whiping a document during an update.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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