@downcity/services
Install one Downcity package for accounts, balance, usage, Stripe payment, and Creem payment services.
@downcity/services combines the official Downcity services into one package while keeping the capability boundaries clear.
With one installation, you can opt into:
AccountsServicefor registration, login, OAuth, sessions, anduser_tokenBalanceServicefor global wallet, ledger, topups, and redeem codesPaymentServicefor exposing which payment methods the current City supports, together with providers likestripePaymentProviderandcreemPaymentProviderUsageServicefor real user-side service-call facts
Install
pnpm add @downcity/servicesMinimal setup
import { Federation } from "@downcity/city";
import {
AccountsService,
BalanceService,
creemPaymentProvider,
PaymentService,
stripePaymentProvider,
UsageService,
} from "@downcity/services";
const base = new Federation({ db });
const balance = new BalanceService();
base.use(new AccountsService());
base.use(balance);
base.use(new PaymentService({
readTopup: async (topup_id) => await balance.readTopup(topup_id),
finishTopup: async (topup_id, extra) => await balance.finishTopup(topup_id, extra),
providers: [
stripePaymentProvider(),
creemPaymentProvider(),
],
}));
base.use(new UsageService());On the product side, the usual first call is:
const methods = await guest.service("payment").get("methods");Then the frontend can choose the concrete method from methods.items, such as stripe or creem.
Read by capability
- For auth, read Accounts Service
- For wallet flows, read Balance Service
- For usage events, read Usage Service
- For Stripe topups, read Stripe Payment Service
- For Creem topups, read Creem Payment Service