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

@illuma/lifecycle

v0.1.0

Published

Boot & shutdown ordering tokens for @illuma/core DI apps — async init, two-phase graceful drain + teardown

Readme

@illuma/lifecycle

Boot & shutdown ordering tokens for @illuma/core DI applications. Three MultiNodeToken collection points an app drains in order, so independently-registered providers can hook startup and graceful shutdown without knowing about each other.

npm i @illuma/lifecycle

Tokens

  • ASYNC_INIT_NODE — async work to run at boot (connect DB, NATS, warm caches). The app awaits all registered callbacks before serving.
  • SHUTDOWN_DRAIN_NODE — phase 1 of shutdown: stop accepting new work (HTTP/NATS/Telegram intake) and let in-flight handlers finish on a still-live connection.
  • ASYNC_SHUTDOWN_NODE — phase 2: tear down connections/resources, after the drain.
import { ASYNC_INIT_NODE, SHUTDOWN_DRAIN_NODE, ASYNC_SHUTDOWN_NODE } from '@illuma/lifecycle';

providers: [
  ASYNC_INIT_NODE.withValue(async () => db.connect()),
  SHUTDOWN_DRAIN_NODE.withValue(async () => server.stopAcceptingNewRequests()),
  ASYNC_SHUTDOWN_NODE.withValue(async () => db.close()),
];

Register hooks

Prefer the typed helpers over TOKEN.withFactory(...). The factory runs in injection context, so it can nodeInject dependencies and close over them in the hook:

import { provideAsyncInit, provideShutdownDrain, provideAsyncShutdown } from '@illuma/lifecycle';

providers: [
  provideAsyncInit(() => {
    const db = nodeInject(DATABASE);
    return () => db.connect();
  }),
  provideShutdownDrain(() => () => server.stopAcceptingNewRequests()),
  provideAsyncShutdown(() => () => db.close()),
];

Drive them (runtime)

The runtime that owns the container injects each collection and runs it at the right phase. The runners encapsulate ordering + failure isolation, so you don't re-roll it:

import { runAsyncInit, runShutdown } from '@illuma/lifecycle';

// boot — sequential, fail-fast (a bad init must abort startup)
await runAsyncInit(nodeInject(ASYNC_INIT_NODE));

// SIGTERM — drain intake (concurrent), then tear down (sequential). A failing
// hook is isolated so it can't strand the rest; surface it via onError.
await runShutdown(
  nodeInject(SHUTDOWN_DRAIN_NODE),
  nodeInject(ASYNC_SHUTDOWN_NODE),
  (err) => logger.error('shutdown hook failed', err),
);

runShutdownDrain and runAsyncShutdown are exported too if you need the phases apart.

RxJS interop (optional)

takeUntilDestroyed lives in a separate @illuma/lifecycle/rxjs entry so the main package never pulls in RxJS. Importing @illuma/lifecycle adds zero RxJS to your bundle; RxJS is an optional peer dependency — only install it if you use this subpath.

npm i rxjs

It completes a stream when the node's LifecycleRef fires beforeDestroy, so subscriptions tear down with the node instead of leaking past it. Called in injection context it resolves the LifecycleRef itself; pass one explicitly otherwise.

import { takeUntilDestroyed } from '@illuma/lifecycle/rxjs';

// in injection context — LifecycleRef is injected for you
interval(1000)
  .pipe(takeUntilDestroyed())
  .subscribe((n) => logger.debug('tick', n));

// or hand it an explicit ref
source$.pipe(takeUntilDestroyed(lifecycleRef)).subscribe(...);

License

MIT