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

@tlsft/service-key

v0.6.0

Published

The service key — [METHOD] [service]/resource — a string naming one call to one service

Readme

@tlsft/service-key

Name a call by the service that answers it, not by where that service lives:

POST [billing]/invoices

Why a service key

A URL answers where: a host, a port, a protocol. Once that's written into a caller, every move becomes a code change: a service splits off, a region is added, a tenant's data has to stay on its own infrastructure. A service key answers what: which service, which resource, which verb. Where the call goes is then a lookup from service to address, and that lookup can differ per environment, per network or per tenant without touching callers.

  • Transport-neutral. The verb is optional, so REST (GET [users]/:id) and RPC ([helloworld.Greeter]/SayHello) share one grammar.
  • One name everywhere. The same string can serve as the route, the access rule and the log line. Wildcards (* [*]/**) parse with the same grammar, so access rules use it too.
  • Small. No dependencies; it parses and formats, and leaves resolution and matching to you.

Grammar

[METHOD] [service]/resource

| Key | Meaning | | --- | --- | | POST [billing]/invoices | REST call | | [helloworld.Greeter]/SayHello | no verb (method: null) | | GET [@billing]/invoices | confined: true: the call's data stays in the caller's own custody, never sent to a host it doesn't hold; the library only records the flag | | * [*]/** | wildcard pattern |

Use

import {parseServiceKey, formatServiceKey} from '@tlsft/service-key'

parseServiceKey('POST [billing]/invoices')
// {method: 'POST', service: 'billing', resource: '/invoices', confined: false}

formatServiceKey({service: 'helloworld.Greeter', resource: '/SayHello'})
// '[helloworld.Greeter]/SayHello'

parseServiceKey returns null for anything that isn't a key, so a caller can ask "is this a key?" and raise its own error with its own context. formatServiceKey throws a TypeError on malformed parts: that's a programming error, not a question.

Parts are what an answering service should match on; the string form is just the caller's notation. serviceKeyFormat bundles the pair as {parse, format}, so a different notation can be another pair, and code written against parts doesn't change.

Rust

The service-key crate implements the same grammar, checked against the same test cases (test/cases.json), and its version tracks this package's. It parses with regress, an ECMAScript regex engine, so the pattern and its meaning are the same as here.

use service_key::ServiceKey;

let key = ServiceKey::parse("POST [@billing]/invoices").unwrap();
// ServiceKey {method: Some("POST"), service: "billing", resource: "/invoices", confined: true}

key.to_string()
// "POST [@billing]/invoices"

ServiceKey::parse returns None for anything that isn't a key. Parts are typed, so formatting cannot fail.

Related

MicroQL uses service keys to name the service calls in a query.