| 1234567891011121314151617181920212223242526272829303132 |
- 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)
- }
|