@dhruvp13/promo-code-adapters
v0.1.0
Published
`CouponRepository` implementations for `@dhruvp13/promo-code-core` against real databases.
Downloads
73
Maintainers
Readme
@dhruvp13/promo-code-adapters
CouponRepository implementations for @dhruvp13/promo-code-core against real databases.
Install
bun add @dhruvp13/promo-code-adapters @dhruvp13/promo-code-corePayload CMS
import { PayloadCouponRepository } from '@dhruvp13/promo-code-adapters/payload'
import { validateCoupon } from '@dhruvp13/promo-code-core'
import { getPayload } from 'payload'
const payload = await getPayload({ config })
const repo = new PayloadCouponRepository(payload)
const result = await validateCoupon(repo, {
code: 'SAVE20',
userId: 'user-1',
purchaseType: 'coin',
baseAmount: 5000,
})Requires payload >= 2.0.0 as a peer dependency, plus the
coupon-codes and coupon-code-redemptions collections (see the
root README for the
expected schema).
