GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
809 B

  1. package services
  2. import (
  3. "git.aiterp.net/rpdata/api/database"
  4. "git.aiterp.net/rpdata/api/services/loaders"
  5. )
  6. // A Bundle contains all services.
  7. type Bundle struct {
  8. Tags *TagService
  9. Characters *CharacterService
  10. Changes *ChangeService
  11. Logs *LogService
  12. }
  13. // NewBundle creates a new bundle.
  14. func NewBundle(db database.Database) *Bundle {
  15. bundle := &Bundle{}
  16. bundle.Changes = &ChangeService{
  17. changes: db.Changes(),
  18. }
  19. bundle.Tags = &TagService{tags: db.Tags()}
  20. bundle.Characters = &CharacterService{
  21. characters: db.Characters(),
  22. loader: loaders.CharacterLoaderFromRepository(db.Characters()),
  23. changeService: bundle.Changes,
  24. }
  25. bundle.Logs = &LogService{
  26. logs: db.Logs(),
  27. posts: db.Posts(),
  28. changeService: bundle.Changes,
  29. }
  30. return bundle
  31. }