pioj

package
v0.0.0-...-21b1631 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendMail

func SendMail(config SMTPConfiguration, to []string, subject string, body string) error

func SetUnique

func SetUnique(ctx context.Context, collection *mongo.Collection, field string) (string, error)

Types

type App

type App struct {
	Configuration
	ServeMux *http.ServeMux
	Database *mongo.Database
	Redis    *redis.Client
	Root     string
	Fallback string
}

func NewApp

func NewApp(config Configuration, database *mongo.Database, rdb *redis.Client) App

func (App) Handle

func (app App) Handle()

func (App) HandleProblems

func (app App) HandleProblems()

func (App) HandleUsers

func (app App) HandleUsers()

type Configuration

type Configuration struct {
	SMTP SMTPConfiguration
}

type IOExample

type IOExample [2]string

type LocalizedStrings

type LocalizedStrings map[string]string

type NotFoundFallbackRespWr

type NotFoundFallbackRespWr struct {
	http.ResponseWriter // We embed http.ResponseWriter
	// contains filtered or unexported fields
}

func (*NotFoundFallbackRespWr) Write

func (w *NotFoundFallbackRespWr) Write(p []byte) (int, error)

func (*NotFoundFallbackRespWr) WriteHeader

func (w *NotFoundFallbackRespWr) WriteHeader(status int)

type Problem

type Problem struct {
	ObjectId     primitive.ObjectID `json:"_id"           bson:"_id"`
	ID           int                `json:"id"`
	Title        LocalizedStrings   `json:"title"`
	Difficulty   int                `json:"difficulty"`
	InputFile    string             `json:"input_file"    bson:"inputFile"`
	OutputFile   string             `json:"output_file"   bson:"outputFile"`
	TimeLimit    int                `json:"time_limit"    bson:"timeLimit"`
	MemoryLimit  int                `json:"memory_limit"  bson:"memoryLimit"`
	Background   LocalizedStrings   `json:"background"`
	Description  LocalizedStrings   `json:"description"`
	InputFormat  LocalizedStrings   `json:"input_format"  bson:"inputFormat"`
	OutputFormat LocalizedStrings   `json:"output_format" bson:"outputFormat"`
	Examples     []IOExample        `json:"examples"`
	Hints        LocalizedStrings   `json:"hints"`
	Tags         []ProblemTag       `json:"tags"`
	Subtasks     []Subtask          `json:"subtasks"`
}

type ProblemTag

type ProblemTag string

type SMTPConfiguration

type SMTPConfiguration struct {
	From     string
	Username string
	Password string
	Host     string
	Port     int
}

type Subtask

type Subtask []TestCase

type TestCase

type TestCase [2]string

type User

type User struct {
	ObjectId primitive.ObjectID `json:"_id" bson:"_id"`
	Username string             `json:"username"`
	Password []byte             `json:"-"`
	Email    string             `json:"email"`
}

func (*User) CheckPassword

func (user *User) CheckPassword(password string) bool

func (*User) Create

func (user *User) Create(ctx context.Context, collection *mongo.Collection) (*mongo.InsertOneResult, error)

func (User) Get

func (User) Get(ctx context.Context, collection *mongo.Collection, filter any) (user User, err error)

func (*User) Save

func (user *User) Save(ctx context.Context, collection *mongo.Collection) (any, error)

func (*User) SetPassword

func (user *User) SetPassword(password string) (err error)

func (*User) Update

func (user *User) Update(ctx context.Context, collection *mongo.Collection) (*mongo.UpdateResult, error)

type UserWithPasswordAndVerification

type UserWithPasswordAndVerification struct {
	User
	Password     string `json:"password"`
	Verification string `json:"verification"`
}

type UsernameAndPassword

type UsernameAndPassword struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Jump to

Keyboard shortcuts

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