Closed chase-moskal closed 1 year ago
ideas for an improved listing service
fetch-subscription-plans.ts
, and we don't even write a single monolithic obtain-subscription-plans.ts
either --listPlans
function really easy to read and understand
import * as renraku from "renraku"
import {StoreServiceOptions} from "../../types/options.js"
export const makeSubscriptionListingService = (options: StoreServiceOptions) =>
renraku
.service()
.policy(options.storePolicies.connected)
.expose(auth => ({
async listPlans() {
const {planRows, tierRows} =
await queryDatabaseAboutSubscriptionPlans(auth)
const {stripeProducts, stripePrices} =
await queryStripeAboutSubscriptionPlans({
auth,
planRows,
tierRows,
})
await performSelfHealingRoutinesForSubscriptionPlans({
auth,
planRows,
tierRows,
stripeProducts,
stripePrices,
})
return compileDataTogetherIntoSubscriptionPlansForFrontend({
auth,
planRows,
tierRows,
stripeProducts,
stripePrices,
})
},
}))
this is a replacement for fetch-subscription-plans.ts
desirable traits of an improved system
pricing
object for the returned subscription plan beundefined
-- which means SubscriptionPlan.pricing can be marked optional in the interfacehelpers-for-managing-subscriptions.ts