lib

package
v0.0.0-...-e8c5ec3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WarningLogger *log.Logger
	InfoLogger    *log.Logger
	ErrorLogger   *log.Logger
)
View Source
var PORT = fmt.Sprintf(":%s", strconv.Itoa(int(iPORT)))

Functions

func AddPolygon

func AddPolygon(compressed_polygon_list []string, addedBy, addedTime string, isInDanger bool) error

func FileNameAnalyzer

func FileNameAnalyzer(filename string) (bool, string)

func GeoCodeQuery

func GeoCodeQuery(latitude, longitude string) (string, int, error)

func GetTime

func GetTime() string

func InitializeLogger

func InitializeLogger()

func LogError

func LogError(err error)

func RandomIDGenerator

func RandomIDGenerator() string

func SetupApi

func SetupApi() *gin.Engine

Types

type AddPolygon_RequestPayload

type AddPolygon_RequestPayload struct {
	Polygon    []string `json:"polygon"`
	AddedBy    UserID   `json:"addedBy"`
	AddedTime  TimeStr  `json:"addedTime"`
	IsInDanger bool     `json:"is_in_danger"`
}

type Config

type Config struct {
	// Port number of server.
	Port uint16
	// All APIs authorization keys for 3rd party microservices.
	ApiKeys map[string]string
}

func NewConfig

func NewConfig() Config

func (Config) GetApiKeys

func (c Config) GetApiKeys(key string) string

func (*Config) GetPort

func (c *Config) GetPort() uint16

func (Config) LoggingPort

func (c Config) LoggingPort()

func (*Config) SetApiKeys

func (c *Config) SetApiKeys(key_name, value_name string)

func (*Config) SetPort

func (c *Config) SetPort(port uint16)

type Configuration

type Configuration interface {
	// constructor
	NewConfig() Config

	// @getter: Config.Port
	GetPort() uint16
	// @setter: Config.Port
	SetPort(port uint16)
	// @logger: Config.Port
	LogginPort()

	// @setter: ApiKeys (from .env file in the root of the project: server folder directory).
	SetApiKeys()
	// @getter: ApiKeys (from .env file in the root of the project: server folder directory).
	GetApiKeys(key string) string
}

type Coordinates

type Coordinates []float64

type Database

type Database struct {
	DBUri                   string
	DBClient                *mongo.Client
	DBCurrentCollection     *mongo.Collection
	DBName                  string
	DBCurrentCollectionName string
}

func NewDB

func NewDB(db_name string) Database

CREATE NEW DB

func (*Database) AddLocation

func (db *Database) AddLocation(doc bson.D) error

func (*Database) ConnectDB

func (db *Database) ConnectDB(collection_name string) *mongo.Collection

DB CONNECTION

func (*Database) DeleteOneQuery

func (db *Database) DeleteOneQuery(filter bson.D) bool

func (*Database) DumpLocations

func (db *Database) DumpLocations() ([]Locations, error)

func (*Database) FindOneUser

func (db *Database) FindOneUser(document bson.D) (User, error)

type DatabaseManagement

type DatabaseManagement interface {
	NewDB(db_name string)
	ConnectDB(collection_name string)
	FindOneUser(filter bson.D) bson.M
	DeleteOneQuery(filter bson.D) bool
}

type ImageUpload

type ImageUpload struct {
	Image *multipart.FileHeader `form:"image_upload", binding:"required"`
}

type ImageUploadWithID

type ImageUploadWithID struct {
	Id          string `uri:"id"`
	ImageUpload ImageUpload
}

type Locations

type Locations struct {
	LocationID primitive.ObjectID `bson:"_id"`
	Polygon    []Coordinates      `bson:"polygon"`
	AddedTime  string             `bson:"added_time"`
	AddedBy    string             `bson:"added_by"`
	IsInDanger bool               `bson:"is_in_danger"`
}

func FetchAllPolygons

func FetchAllPolygons() ([]Locations, error)

type TimeStr

type TimeStr string

/ strftime string format keeper.

type User

type User struct {
	UserID   primitive.ObjectID `bson:"_id"`
	Username string
	Password string
}

func FindUser

func FindUser(username, password string) (User, error)

func GetUserByID

func GetUserByID(user_id string) (User, error)

func ValidateLogin

func ValidateLogin(username, password string) (User, error)

type UserID

type UserID string

/ UserID is equal to BSON ObjectID but in Hex/String format.

type Username

type Username string

/ Username = Ex: "yigit" / "admin".

Jump to

Keyboard shortcuts

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