core

package
v0.0.0-...-4831141 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeoutInSeconds = 30
)

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Services Services
}

func InitApp

func InitApp() *App

func (*App) InitServices

func (a *App) InitServices(services Services)

func (*App) Service

func (a *App) Service(name string) (*Service, error)

type Config

type Config struct {
	PORT       int
	DATABASE   DatabaseConfig
	STAGE      string
	AUDIENCE   string
	JWT_SECRET string
	JWT_EXPIRY int
	MAILER     MailerConfig
}

func Configuration

func Configuration() *Config

type Controller

type Controller func(params map[string]interface{}) error

type CreateHandler

type CreateHandler func(customPayload interface{}, customOptions CreateHandlerOptions) CreateHandlerResponse

type CreateHandlerOptions

type CreateHandlerOptions = *options.InsertOneOptions

type CreateHandlerResponse

type CreateHandlerResponse struct {
	Result    *mongo.InsertOneResult
	Exception error
}

type Database

type Database = mongo.Database

func InitDatabase

func InitDatabase() *Database

type DatabaseConfig

type DatabaseConfig struct {
	HOST     string
	PORT     string
	USER     string
	PASSWORD string
	NAME     string
}

type DeleteHandler

type DeleteHandler func(customFilter interface{}, customOptions DeleteHandlerOptions) DeleteHandlerResponse

type DeleteHandlerOptions

type DeleteHandlerOptions = *options.FindOneAndDeleteOptions

type DeleteHandlerResponse

type DeleteHandlerResponse struct {
	Result    *mongo.SingleResult
	Exception error
}

type Entity

type Entity struct {
	Ctx        context.Context
	Collection *mongo.Collection
}

type Event

type Event struct {
	Data     interface{}
	Listener chan interface{}
}

func InitEvent

func InitEvent() *Event

func (*Event) Publish

func (e *Event) Publish(data interface{})

func (*Event) Subscribe

func (e *Event) Subscribe() <-chan interface{}

func (*Event) Unsubscribe

func (e *Event) Unsubscribe()

type Extras

type Extras struct {
	Authenticate bool
	Authorize    bool
}

type FindHandler

type FindHandler func(customFilter interface{}, customOptions FindHandlerOptions) FindHandlerResponse

type FindHandlerOptions

type FindHandlerOptions = *options.FindOptions

type FindHandlerResponse

type FindHandlerResponse struct {
	Result    *mongo.Cursor
	Exception error
}

type GetHandler

type GetHandler func(customFilter interface{}, customOptions GetHandlerOptions) GetHandlerResponse

type GetHandlerOptions

type GetHandlerOptions = *options.FindOneOptions

type GetHandlerResponse

type GetHandlerResponse struct {
	Result    *mongo.SingleResult
	Exception error
}

type Handler

type Handler struct {
	Find   FindHandler
	Get    GetHandler
	Create CreateHandler
	Patch  PatchHandler
	Delete DeleteHandler
}

type HookFunc

type HookFunc func(c *fiber.Ctx) error

type Hooks

type Hooks struct {
	Before  HookFunc
	After   HookFunc
	OnError HookFunc
}

type MailerConfig

type MailerConfig struct {
	FROM string
}

type Name

type Name = string

type PatchHandler

type PatchHandler func(customFilter interface{}, customPayload interface{}, customOptions PatchHandlerOptions) PatchHandlerResponse

type PatchHandlerOptions

type PatchHandlerOptions = *options.FindOneAndUpdateOptions

type PatchHandlerResponse

type PatchHandlerResponse struct {
	Result    *mongo.SingleResult
	Exception error
}

type Path

type Path = string

type Route

type Route struct {
	Path       string
	Controller Controller
	Extras     Extras
}

type Router

type Router map[string]Route

type Server

type Server struct {
	Port     int
	Engine   *fiber.App
	App      *App
	Database *Database
}

func Build

func Build() *Server

func (*Server) Boot

func (s *Server) Boot() error

type ServerError

type ServerError struct {
	Status  int    `json:"status"`
	Title   string `json:"title"`
	Message string `json:"message"`
}

func (*ServerError) Error

func (e *ServerError) Error() string

type Service

type Service struct {
	Name    Name
	Path    Path
	Entity  Entity
	Handler Handler
	Router  Router
	Hooks   Hooks
}

func Create

func Create() *Service

func (*Service) AddPrivateRoute

func (s *Service) AddPrivateRoute(method string, controller func(params map[string]interface{}) error, path ...string) *Service

func (*Service) AddProtectedRoute

func (s *Service) AddProtectedRoute(method string, controller func(params map[string]interface{}) error, path ...string) *Service

func (*Service) AddPublicRoute

func (s *Service) AddPublicRoute(method string, controller func(params map[string]interface{}) error, path ...string) *Service

func (*Service) Bind

func (s *Service) Bind(controller func(params map[string]interface{}) error, server *Server) func(c *fiber.Ctx) error

func (*Service) SetEntity

func (s *Service) SetEntity(e Entity) *Service

func (*Service) SetHooks

func (s *Service) SetHooks(h Hooks) *Service

func (*Service) SetName

func (s *Service) SetName(n Name) *Service

func (*Service) SetPath

func (s *Service) SetPath(p Path) *Service

type Services

type Services map[string]*Service

Jump to

Keyboard shortcuts

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