Exposed OfferRepository from OffersModule

refs https://github.com/TryGhost/Team/issues/1090

When creating checkout session we will need to be able to look up Offers
from the OfferRepository. This exposes the repository so that it can be
passed as a dependency elsewhere.
This commit is contained in:
Fabien O'Carroll 2021-10-06 14:58:55 +02:00
parent 371581f677
commit d57d082c39
2 changed files with 5 additions and 6 deletions

View File

@ -7,9 +7,11 @@ class OffersModule {
/**
* @param {OffersAPI} offersAPI
* @param {import('@tryghost/express-dynamic-redirects')} redirectManager
* @param {OfferRepository} repository
*/
constructor(offersAPI, redirectManager) {
constructor(offersAPI, redirectManager, repository) {
this.api = offersAPI;
this.repository = repository;
this.redirectManager = redirectManager;
}
@ -52,7 +54,7 @@ class OffersModule {
static create(deps) {
const repository = new OfferRepository(deps.OfferModel, deps.stripeAPIService);
const offersAPI = new OffersAPI(repository);
return new OffersModule(offersAPI, deps.redirectManager);
return new OffersModule(offersAPI, deps.redirectManager, repository);
}
}

View File

@ -33,15 +33,12 @@ class OfferRepository {
/**
* @param {{forge: (data: object) => import('bookshelf').Model<Offer.OfferProps>}} OfferModel
* @param {import('@tryghost/members-stripe-service')} stripeAPIService
* @param {import('@tryghost/express-dynamic-redirects')} redirectManager
*/
constructor(OfferModel, stripeAPIService, redirectManager) {
constructor(OfferModel, stripeAPIService) {
/** @private */
this.OfferModel = OfferModel;
/** @private */
this.stripeAPIService = stripeAPIService;
/** @private */
this.redirectManager = redirectManager;
}
/**