33 lines
643 B
Go
33 lines
643 B
Go
package service
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"cmr-backend/internal/apperr"
|
|
"cmr-backend/internal/store/postgres"
|
|
)
|
|
|
|
type DevService struct {
|
|
appEnv string
|
|
store *postgres.Store
|
|
}
|
|
|
|
func NewDevService(appEnv string, store *postgres.Store) *DevService {
|
|
return &DevService{
|
|
appEnv: appEnv,
|
|
store: store,
|
|
}
|
|
}
|
|
|
|
func (s *DevService) Enabled() bool {
|
|
return s.appEnv != "production"
|
|
}
|
|
|
|
func (s *DevService) BootstrapDemo(ctx context.Context) (*postgres.DemoBootstrapSummary, error) {
|
|
if !s.Enabled() {
|
|
return nil, apperr.New(http.StatusNotFound, "not_found", "dev bootstrap is disabled")
|
|
}
|
|
return s.store.EnsureDemoData(ctx)
|
|
}
|