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

@openreachtech/mentsu-rocket-client

v1.3.2

Published

Rocket client module (by [email protected])

Readme

@openreachtech/mentsu-rocket-client

A small, class-based REST client framework for building type-safe HTTP API clients.

Each API endpoint is modeled as three cooperating classes — a Payload (what to send), a Launcher (how to send it), and a Capsule (what came back) — so that request building, transport, and response handling stay separated and easy to extend.

Table of contents

Concept

An API call is described by three classes you extend:

| Class | Responsibility | | :-- | :-- | | BasePayload | Describes one endpoint: HTTP method, pathname (with path parameters), query, body, Content-Type, and authorization. Builds the fetch Request. | | BaseLauncher | Holds the client configuration (base URL), wires a Payload to a Capsule, and runs the request through fetch with optional lifecycle hooks. | | BaseCapsule | Wraps the raw Response: exposes the parsed body and status code, and answers whether the call succeeded or which error occurred. |

Optionally, a BaseEntity can be bound to the triad with .via(EntityCtor) so that responses are materialized into your own domain objects.

Installation

Requires Node.js 20.x (the version the CI builds against).

This package is published to GitHub Packages under the @openreachtech scope. Before installing, the following two steps are required:

  1. Add the registry to your project's .npmrc:

    @openreachtech:registry=https://npm.pkg.github.com
  2. Authenticate with npm login:

    npm login --registry https://npm.pkg.github.com

Then install:

npm install @openreachtech/mentsu-rocket-client

It is an ES module ("type": "module"); import it with ESM import syntax.

Usage

1. Define an endpoint

Extend BasePayload, BaseCapsule, and BaseLauncher to describe one endpoint.

import {
  BaseLauncher,
  BasePayload,
  BaseCapsule,
  REST_METHOD,
} from '@openreachtech/mentsu-rocket-client'

class GetCustomerPayload extends BasePayload {
  /** @override */
  static get method () {
    return REST_METHOD.GET
  }

  /** @override */
  static get pathname () {
    return '/customers/[customerId]' // [customerId] is filled from pathParameterHash
  }

  /** @override */
  static get contentType () {
    return 'application/json'
  }
}

class GetCustomerCapsule extends BaseCapsule {}

class GetCustomerLauncher extends BaseLauncher {
  /** @override */
  static get clientConfig () {
    return {
      BASE_URL: 'https://api.example.com',
    }
  }

  /** @override */
  static get Payload () {
    return GetCustomerPayload
  }

  /** @override */
  static get Capsule () {
    return GetCustomerCapsule
  }
}

2. Launch a request

const launcher = GetCustomerLauncher.create()

const payload = GetCustomerLauncher.createPayload({
  pathParameterHash: {
    customerId: 10001,
  },
  query: {
    includesDeleted: false,
  },
})

const capsule = await launcher.launchRequest({
  payload,
})

if (capsule.hasError()) {
  console.error(capsule.getErrorMessage()) // error code string
} else {
  console.log(capsule.statusCode) // e.g. 200
  console.log(capsule.body) // parsed response body
}

3. Lifecycle hooks

beforeRequest can abort the request (return true); afterRequest observes the resolved capsule.

const capsule = await launcher.launchRequest({
  payload,
  hooks: {
    async beforeRequest (payload) {
      return false // return true to abort the request
    },
    async afterRequest (capsule) {
      // inspect the resolved capsule
    },
  },
})

4. Authorization

Set an authorization builder and the API key on the payload. BearerAuthorizationBuilder and BasicAuthorizationBuilder are provided.

import {
  BasePayload,
  BearerAuthorizationBuilder,
  REST_METHOD,
} from '@openreachtech/mentsu-rocket-client'

class CreateOrderPayload extends BasePayload {
  /** @override */
  static get method () {
    return REST_METHOD.POST
  }

  /** @override */
  static get pathname () {
    return '/orders'
  }

  /** @override */
  static get contentType () {
    return 'application/json'
  }

  /** @override */
  static get AuthorizationBuilderCtor () {
    return BearerAuthorizationBuilder
  }

  /** @override */
  static get authorizationApiKey () {
    return process.env.API_TOKEN // credential source
  }
}

Notes

  • Validation: assign a schema to the static querySchema / bodySchema fields of a Payload, or to bodySchema of a Capsule, to validate inputs and normalize the response body. A payload with an invalid query, body, or path parameter resolves to a capsule whose hasError() is true.
  • Key casing: use SnakeCasedKeyRequestQuery / SnakeCasedKeyRequestBody to send snake_case keys over the wire, and CamelCasedKeyResponseBody to receive camelCase keys in JavaScript.
  • Body format: the default request body is JSON. Set BodyStringifierCtor to NdjsonRequestBodyStringifier for NDJSON.
  • Response parsing: override ResponseBodyParser on the launcher to change how the response body is parsed (JsonResponseBodyParser by default, BlobResponseBodyParser for binary responses).

API

Detailed API references for the base classes are split by class:

API references

Contribution

Bug reports, feature requests, and code contributions are welcome.

Feel free to contact us through GitHub Issues.

git clone https://github.com/openreachtech/mentsu-rocket-client.git
cd mentsu-rocket-client
npm install
npm run lint
npm test

License

This project is released under the Apache License 2.0.

For more details, please see in the LICENSE file.

Developer

Open Reach Tech Inc.

Copyright

© 2026 Open Reach Tech Inc.