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

@redonvn/shipping-grabexpress

v1.1.0

Published

Production-ready GrabExpress On-Demand Delivery API SDK for RedAI Monorepo (OAuth2, Quotes, GPS Tracking)

Readme

@redai/shipping-grabexpress

SDK TypeScript chuẩn doanh nghiệp kết nối GrabExpress On-Demand Delivery API (Giao hàng tức thì / Siêu tốc / Trong ngày bằng xe máy) trong Monorepo Logistics RedAI.


🌟 TÍNH NĂNG NỔI BẬT

  1. OAuth 2.0 Client Credentials Grant:
    • Tự động lấy Access Token từ máy chủ GrabID.
    • Cơ chế Cache token thông minh kèm bộ đệm 60s trước khi hết hạn.
    • Lifecycle Hook tự động bắt lỗi 401 Unauthorized để cấp lại token và retry trong suốt với ứng dụng.
  2. Quy trình Đặt xe 2 bước chuẩn On-Demand:
    • Bước 1: Lấy báo giá Quotes ➔ Trả về cước phí, thời gian đón/giao và quoteToken có hiệu lực 5-10 phút để khóa giá.
    • Bước 2: Đặt xe Create Delivery bằng quoteToken để điều phối tài xế gần nhất.
  3. Theo dõi thời gian thực (Live GPS Driver Tracking):
    • Truy vấn thông tin tài xế: Họ tên, Số điện thoại, Biển số xe.
    • Tọa độ GPS thời gian thực (Latitude, Longitude) của tài xế trên bản đồ.
  4. Bảo mật Webhook HMAC-SHA256:
    • Xác thực chữ ký số X-Grab-Signature bằng cơ chế an toàn crypto.timingSafeEqual.
    • Ánh xạ tự động trạng thái Grab sang CanonicalShippingStatus (ASSIGNING_DRIVER, PICKING_UP, DELIVERING, DELIVERED, CANCELLED...).
  5. Tuân thủ Chuẩn Speakeasy Monorepo:
    • Thuật toán Exponential Backoff kết hợp Full Jitter cho 429 Too Many Requests và lỗi máy chủ 5xx.
    • Triển khai đầy đủ interface đa nền tảng IShippingProvider.

🚀 CÀI ĐẶT & SỬ DỤNG NHANH

import { GrabExpressClient } from '@redai/shipping-grabexpress';

const client = new GrabExpressClient({
  clientId: process.env.GRAB_CLIENT_ID,
  clientSecret: process.env.GRAB_CLIENT_SECRET,
  webhookSecret: process.env.GRAB_WEBHOOK_SECRET,
  env: 'staging' // 'staging' hoặc 'production'
});

// 1. Lấy báo giá và quoteToken
const quote = await client.quotes.getQuotes({
  serviceType: 'INSTANT',
  origin: { address: 'Bitexco Financial Tower, Quận 1, TP.HCM' },
  destination: { address: 'Landmark 81, Bình Thạnh, TP.HCM' },
  packages: [
    { name: 'Cà phê & Bánh ngọt', quantity: 1, price: 150000, dimensions: { weight: 500 } }
  ]
});

console.log('Giá cước:', quote.quotes[0].amount, quote.quotes[0].currency);

// 2. Tạo đơn đặt xe
const delivery = await client.deliveries.create({
  merchantOrderID: 'ORDER_' + Date.now(),
  quoteToken: quote.quoteToken,
  sender: { firstName: 'Nguyễn', lastName: 'Văn A', phone: '+84912345678' },
  recipient: { firstName: 'Trần', lastName: 'Thị B', phone: '+84987654321' }
});

console.log('Mã đơn Grab:', delivery.deliveryID);