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

@nogg-aholic/nrpc-restate

v0.1.3

Published

Helpers to register and bind Restate services, virtual objects, and workflows

Readme

nRPC Restate Kit

@nogg-aholic/nrpc-restate provides lightweight registration helpers for Restate components.

It is designed for codebases where each module can register itself and a central bootstrap can bind everything to a Restate endpoint.

Install

With Bun:

bun add @nogg-aholic/nrpc-restate @restatedev/restate-sdk

With npm:

npm install @nogg-aholic/nrpc-restate @restatedev/restate-sdk

Quick Start

import * as restate from '@restatedev/restate-sdk';
import {
  bindRegisteredRestateComponents,
  defineRestateComponent,
  registerRestateComponent,
} from '@nogg-aholic/nrpc-restate';

const greeter = restate.service({
  name: 'greeter',
  handlers: {
    greet: async () => 'hello',
  },
});

const billingWorkflow = restate.workflow({
  name: 'billing',
  handlers: {
    run: async () => 'ok',
  },
});

registerRestateComponent(defineRestateComponent(greeter, { kind: 'service' }));
registerRestateComponent(defineRestateComponent(billingWorkflow, { kind: 'workflow' }));

const endpoint = restate.endpoint();
bindRegisteredRestateComponents(endpoint);

One-Line nRPC Surface Registration

If your service already exposes a nested nRPC object (for example from createAuthRpcService()), you can expose the full surface to Restate in one line:

registerRpcSurfaceAsRestateService(createAuthRpcService(), {
  name: 'antigravity-auth',
  restateServiceFactory: restate.service,
});

This scans all nested functions and binds them as Restate handlers.

Default handler naming joins path segments with __:

  • health.status -> health__status
  • accounts.activeCredential -> accounts__activeCredential

You can change naming with handlerNameStrategy: 'dot' | 'slash' | (path) => string.

Self-Hosted Backend Auth Headers

If Restate handlers call a backend protected by PayloadCMS auth, inject headers centrally:

registerRpcSurfaceAsRestateService(createAuthRpcService(), {
  name: 'antigravity-auth',
  restateServiceFactory: restate.service,
  backendRequestHeaders: createPayloadApiKeyHeaders(
    'users',
    process.env.PAYLOADCMS_API_KEY ?? '',
  ),
  backendRequestHeadersTarget: 'auto',
});

Payload API-key auth format is:

  • Authorization: <collectionSlug> API-Key <apiKey>

For example:

  • Authorization: users API-Key <apiKey>

If you are logged into Payload in a browser, local-jwt session cookies may also authenticate requests. Prefer explicit API-key headers for backend-to-backend calls.

backendRequestHeadersTarget options:

  • auto (default): writes to input.headers when present, otherwise headers
  • headers: always writes to top-level headers
  • input.headers: always writes to nested input.headers

For dynamic per-method behavior, use a function:

backendRequestHeaders: ({ path }) =>
  path[0] === 'proxy'
    ? createPayloadApiKeyHeaders('users', process.env.PAYLOADCMS_API_KEY ?? '')
    : undefined,

APIs

  • defineRestateComponent(definition, { kind?, name? })
  • registerRestateComponent(component, { kind?, name? })
  • listRegisteredRestateComponents()
  • clearRegisteredRestateComponents()
  • bindRegisteredRestateComponents(endpoint, options?)
  • bindRestateComponents(endpoint, components, options?)
  • createRestateRegistry()
  • discoverRpcSurfaceMethods(surface, options?)
  • createRestateServiceDefinitionFromRpcSurface(surface, options)
  • registerRpcSurfaceAsRestateService(surface, options)

Duplicate Handling

By default duplicate component registration is rejected by kind:name and throws.

Use bind options to change behavior:

bindRegisteredRestateComponents(endpoint, {
  throwOnDuplicate: false,
  dedupeByName: true,
});

When duplicates are skipped, the return value includes both bound and skipped entries.