@lacspace/courier
Courier / last-mile delivery toolkit — a canonical delivery state machine, tracking-number validation with carrier detection (UPS/FedEx/USPS/DHL + regional, check digits), tracking-event timelines, business-day ETA/SLA, tracking-URL building, a Pathao (Nepal) adapter, and inbound webhook verification + status normalization. Zero-dependency, isomorphic.
npm i @lacspace/courierUsage
import { createPathaoAdapter, verifyPathaoWebhook, parsePathaoWebhook } from "@lacspace/courier";
const pathao = createPathaoAdapter({ clientId, clientSecret, username, password, storeId: 42 });
const shipment = await pathao.createOrder({
recipientName: "Sita", recipientPhone: "98xxxxxxxx",
recipientAddress: "Baneshwor, KTM", amountToCollect: 250000, itemQuantity: 1,
});
// inbound webhook -> canonical status, no more manual clicking
if (verifyPathaoWebhook({ headerSecret: req.headers["x-pathao-signature"], expectedSecret })) {
const evt = parsePathaoWebhook(req.body); // { status: "delivered", consignmentId, ... }
}Exports 11
createPathaoAdaptertransitioncanTransitionisTerminalnormalizePathaoStatusparsePathaoWebhookverifyPathaoWebhookverifyWebhookSignatureDELIVERY_TRANSITIONSPATHAO_STATUS_MAPCourierErrorKeywords
More in Commerce & Ledger
Headless, framework-agnostic shopping-cart engine — pure, immutable & serializable. Line-item options/add-ons, line & cart discounts (%/fixed), injectable tax hooks (inclusive/exclusive), a full totals breakdown, plus serialize/hydrate/merge — all in integer minor units. Isomorphic (Node, edge, browser).
@lacspace/inventoryHeadless stock engine that prevents overselling — reserve/commit/restock over plain { onHand, reserved } state, plus multi-location transfers, reorder points, lot/expiry FIFO-FEFO allocation, and an append-only movements ledger with low-stock & expiring-soon reports. Immutable, bring-your-own-store, isomorphic.
@lacspace/commissionCommission & payout engine — flat/percent/marginal-tier/progressive-slab rules with caps & floors, composite and per-category rates, tax-on-commission (inclusive/exclusive), explicit rounding modes, and a marketplace split (platform + seller + affiliate) whose lines conserve the gross exactly. Integer minor units, zero floats. Isomorphic.
@lacspace/settlementSettlement, netting & reconciliation for marketplace payouts — batch-settle transactions per payee, deduct commission/fees/tax, hold rolling reserves, schedule payout dates (skipping weekends & holidays) and build statements. Integer minor units, pure functions. Isomorphic.
@lacspace/couponDiscount & coupon engine — percent, fixed, free-shipping, BOGO and tiered codes, with validity windows, total/per-user limits, first-order and product/category scope, a currency guard, safe coupon stacking and CSPRNG code generation. Integer minor units, no float drift. Zero-dependency, isomorphic.
@lacspace/taxVAT & sales-tax done right — exact integer minor-unit arithmetic (no float cents bugs), add/extract tax (inclusive & exclusive), multiple & compound taxes with a labelled breakdown, category rate tables, reverse charge, and line-level vs invoice-level rounding. Isomorphic.