package services import ( "git.aiterp.net/rpdata/api/database" "git.aiterp.net/rpdata/api/services/loaders" ) // A Bundle contains all services. type Bundle struct { Tags *TagService Characters *CharacterService Changes *ChangeService Logs *LogService Channels *ChannelService } // NewBundle creates a new bundle. func NewBundle(db database.Database) *Bundle { bundle := &Bundle{} bundle.Changes = &ChangeService{ changes: db.Changes(), } bundle.Tags = &TagService{tags: db.Tags()} bundle.Characters = &CharacterService{ characters: db.Characters(), loader: loaders.CharacterLoaderFromRepository(db.Characters()), changeService: bundle.Changes, } bundle.Channels = &ChannelService{ channels: db.Channels(), loader: loaders.ChannelLoaderFromRepository(db.Channels()), changeService: bundle.Changes, } bundle.Logs = &LogService{ logs: db.Logs(), posts: db.Posts(), changeService: bundle.Changes, } return bundle }