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

app-leaf

v0.1.0

Published

A brief description of my npm package.

Readme

App Leaf Package

A lightweight, decorator-based lifecycle and dependency injection framework for TypeScript applications.

Installation

# Using npm
npm install app-leaf

# Using Bun
bun add app-leaf

Important Import Warning

When using controllers, always use regular imports rather than type-only imports:

import type { SomeController } from "./SomeController"; // BAD: Will cause errors during dependency injection

import { SomeController } from "./SomeController"; // GOOD: Ensures proper controller registration

Type-only imports prevent the controller class from being registered properly in the dependency injection system.

Features

  • Decorator-based controller registration
  • Controlled lifecycle with initialization and start hooks
  • Automatic dependency injection
  • Module system for organizing controllers
  • Prevention of cyclic dependencies
  • Load order control

Usage

Basic Example

import { Controller, OnInit, OnStart, AppLeaf } from "app-leaf";

@Controller()
class HelloController {
  @OnInit()
  private init() {
    console.log("HelloController initialized");
  }

  @OnStart()
  private start() {
    console.log("HelloController started");
  }

  sayHello() {
    return "Hello, world!";
  }
}

@Controller()
class AppController {
  constructor(private readonly helloController: HelloController) {}

  @OnStart()
  private start() {
    console.log(this.helloController.sayHello());
  }
}

// Start the application lifecycle
AppLeaf.Start();

Using Modules

import { Controller, Module, AppLeaf } from "app-leaf";

@Controller()
class UserController {
  getUsers() {
    return ["User1", "User2"];
  }
}

@Controller()
class ProductController {
  getProducts() {
    return ["Product1", "Product2"];
  }
}

@Module([UserController, ProductController])
class FeatureModule {}

// To ensure all controllers are imported
AppLeaf.LoadModules([FeatureModule]);
AppLeaf.Start();

Controlling Load Order

@Controller({ loadOrder: 1 })
class FirstController {}

@Controller({ loadOrder: 2 })
class SecondController {}

Using the Dependency Utility

import { Controller, OnStart, Dependency, AppLeaf } from "app-leaf";

@Controller()
class ServiceController {
  getData() {
    return "Service Data";
  }
}

@Controller()
class ConsumerController {
  @OnStart()
  private start() {
    // Get controller reference after initialization
    const service = Dependency(ServiceController);
    console.log(service.getData());
  }
}

AppLeaf.Start();

API Reference

Decorators

@Controller(options?: { loadOrder?: number })

Registers a class as a controller in the application lifecycle.

  • loadOrder: Optional number that determines initialization order (lower values initialize first)

@OnInit()

Marks a method to be called during the initialization phase, before dependency injection.

@OnStart()

Marks a method to be called after all controllers are initialized and injected.

@Module(controllers: any[])

Registers a class as a module containing a list of controllers.

Functions

Dependency<T>(controllerClass: new (...args: any) => T): T

Gets an instance of a registered controller after initialization.

  • Should primarily be used within OnStart methods or after AppLeaf.Start()
  • Throws error if controller is not registered or not loaded yet

AppLeaf Namespace

AppLeaf.LoadModules(modules: any[])

Ensures that all controllers in the provided modules are imported.

AppLeaf.Start()

Starts the application lifecycle:

  1. Initializes all controllers in order of their loadOrder
  2. Resolves dependencies between controllers
  3. Calls OnInit methods
  4. Calls all OnStart methods in parallel

Important Notes

  • If a controller fails in constructor - app stops
  • If a controller fails in OnInit - app stops
  • If a controller fails in OnStart - it logs a warning but the app continues running
  • Cyclic dependencies are detected and prevented