graphicek/server/services/services.go

37 lines
789 B
Go

package services
import (
"basic-sensor-receiver/config"
"database/sql"
)
type Services struct {
SensorConfig *SensorConfigService
SensorValues *SensorValuesService
Sensors *SensorsService
Sessions *SessionsService
Users *UsersService
Auth *AuthService
}
type Context struct {
DB *sql.DB
Config *config.Config
Services *Services
}
func InitializeServices(ctx *Context) *Services {
services := Services{}
ctx.Services = &services
services.SensorConfig = &SensorConfigService{ctx: ctx}
services.SensorValues = &SensorValuesService{ctx: ctx}
services.Sensors = &SensorsService{ctx: ctx}
services.Sessions = &SessionsService{ctx: ctx}
services.Auth = &AuthService{ctx: ctx}
services.Users = &UsersService{ctx: ctx}
return &services
}