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

lodestar-sdk

v0.1.1

Published

Lodestar backend SDK with direct PostgreSQL access

Readme

lodestar-sdk

lodestar-sdk 是以 TypeORM 直連 PostgreSQL 的 backend SDK,整合原本 lodestar-app-backendlodestar-server 的核心商業流程(Order、Payment、Auth、Discount、App Settings)。

安裝

npm install

環境變數

  • POSTGRES_URL:PostgreSQL 連線字串
  • JWT_SECRET:SDK 發行 access token 使用

快速開始

import { createLodestarSDK } from 'lodestar-sdk'

const sdk = createLodestarSDK({
  url: process.env.POSTGRES_URL || '',
  jwtSecret: process.env.JWT_SECRET || 'dev-secret',
})

await sdk.initialize()
const appSettings = await sdk.appService.getAppSettings('app-id')
await sdk.destroy()

主要服務

  • appServicegetApp(), getAppSettings()
  • authServiceregisterMember(), login(), verifyAccessToken()
  • orderServicecreateOrder(), getOrderById()
  • paymentServicemarkPaymentSuccess(), getShouldIssueInvoicePaymentLogs(), issueInvoice()
  • discountServiceredeemCoupon(), redeemVoucher()
  • programServicegetProgramById(), getProgramPlanById()
  • podcastServicegetPodcastProgramById(), getPodcastProgramAudios()
  • activityServicegetActivityTicketById(), getActivitySessions()
  • appointmentServicegetAppointmentPlanById(), getAppointmentSchedules()
  • triggerServicemarkOrderProductDelivered(), appendOrderDeliverable()

範例

npm run example:create-order
npm run example:get-app
npm run example:get-order
npm run example:auth
npm run example:discount
npm run examples:develop

範例檔案位於 examples/

  • examples/create-order.ts
  • examples/get-app.ts
  • examples/get-order.ts
  • examples/auth-register-login.ts
  • examples/discount-redeem.ts

examples:develop 會依序執行:

  1. example:create-order
  2. example:get-order
  3. example:auth
  4. example:discount

請先設定 develop DB 連線環境變數(可由 .env.example 載入):

set -a
source .env.example
set +a

測試

npm test

使用 develop DB 進行整合測試

export RUN_INTEGRATION=1
npm run test:integration

說明:

  • 請將 POSTGRES_URL 指向 develop PostgreSQL。
  • 若 develop DB 缺少測試資料,可先執行 npm run db:seed 匯入 seeds/01-core-seed.sql

功能覆蓋報告

npm run parity:report

報告會輸出到 docs/FEATURE_PARITY_REPORT.md,用來追蹤 lodestar-app-backend / lodestar-serverlodestar-sdk 的功能覆蓋差距。

測試涵蓋:

  • 訂單建立流程(order_log/order_product/order_discount/payment_log 關聯)
  • 付款成功狀態更新
  • 會員註冊與登入 token 發行
  • coupon/voucher 核銷流程