npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@scryan7371/sdr-subscription

v0.1.5

Published

Reusable Stripe-only subscription capability for API and app clients.

Readme

sdr-subscription

Reusable Stripe-only subscription capability for API and app clients.

Scope

This package is intentionally split into two surfaces:

  • api: shared domain contracts + Stripe status mapping helpers.
  • app: typed client for subscription endpoints used by mobile/web app frontends.
  • nest: reusable Nest module/service/controllers/entity for API projects.

Package Layout

  • src/api/contracts.ts: canonical request/response and status/provider types.
  • src/api/stripe.ts: Stripe-to-domain status mapping.
  • src/app/client.ts: client methods for user/admin subscription API calls.
  • src/nest/*: Nest module + service + controllers + entity for subscription operations.

API Integration (Nest)

In your API project:

  1. Import the shared Nest surface:
import { SubscriptionModule } from "@scryan7371/sdr-subscription/nest";
  1. Register it in your API module:
SubscriptionModule.forRoot({
  stripeSecretKey: process.env.STRIPE_SECRET_KEY,
  stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET,
});
  1. Apply your app-specific guards/auth policies in your API app where needed.

App Integration (React Native / Web)

In your app project:

  1. Build client once:
import { app as sdrSubscription } from "@scryan7371/sdr-subscription";

const subscriptionClient = sdrSubscription.createSubscriptionClient({
  baseUrl,
  getAccessToken: () => accessToken,
});
  1. Use methods in screens/services:
  • getMySubscriptionStatus()
  • getMySubscriptions()
  • cancelMySubscription(subscriptionId)
  • cancelSubscriptionAsAdmin(subscriptionId)
  • reactivateSubscriptionAsAdmin(subscriptionId)

Notes

  • This is Stripe-only by design.
  • Keep versions pinned in consumers.

Database Integration Tests

Real database tests are available with:

npm run test:db

The test loader reads DB values from .env.test or .env.dev (current dir first, then project root), using either:

  • SUBSCRIPTION_TEST_DATABASE_URL (or fallback DATABASE_URL), or
  • component vars: DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME.

Debug schema helpers:

npm run test:db:keep
npm run test:db:teardown
  • test:db:keep keeps schema sdr_subscription_it_debug after the run.
  • test:db:teardown runs against the same schema and tears it down.

Publish (npmjs)

  1. Configure project-local npm auth (.npmrc):
registry=https://registry.npmjs.org/
@scryan7371:registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
  1. Set token, bump version, and publish:
export NPM_TOKEN=xxxx
npm version patch
npm publish --access public --registry=https://registry.npmjs.org --userconfig .npmrc
  1. Push commit and tags:
git push
git push --tags

Release Process

Use the built-in release scripts (recommended):

npm run release:patch
npm run release:minor
npm run release:major

Each release script:

  1. Validates git working tree is clean.
  2. Runs tests.
  3. Builds the package.
  4. Bumps package.json/package-lock.json.
  5. Commits as chore(release): vX.Y.Z.
  6. Creates tag sdr-subscription-vX.Y.Z.
  7. Pushes commit and tag.

Tag pushes (sdr-subscription-v*) trigger publish workflow in GitHub Actions.

CI Publish (GitHub Actions)

Tag pushes like sdr-subscription-v* trigger .github/workflows/publish.yml.

Required repo secret:

  • NPM_TOKEN (npm granular token with read/write + bypass 2FA for automation).

Install

Install a pinned version:

npm install @scryan7371/[email protected]