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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ts-phoenix/core

v1.0.0-alpha.5

Published

The heart of the @ts-phoenix ecosystem, providing a robust foundation for building scalable and maintainable web applications in TypeScript.

Readme

@ts-phoenix/core

The heart of the @ts-phoenix ecosystem, providing a robust foundation for building scalable and maintainable web applications in TypeScript.

Features

  • Manage application state and lifecycle
  • Efficiently handle package dependencies
  • Centralized dependency injection for improved code reusability and testability

Installation

Install the package using npm or yarn:

npm i @ts-phoenix/core

Features

Packages

A package is a modular, self-contained unit that encapsulates a specific functionality or feature. Packages can have their own configuration, dependencies, and services. They are designed to be easily combined, allowing developers to build complex applications by assembling multiple packages together. By using packages, you can maintain a clean separation of concerns, promote reusability, and simplify the overall structure of your application.

Core

The Core class serves as the central hub that manages the lifecycle of all packages in your application. It is responsible for initializing packages, handling dependencies, and managing the application state. The Core class provides lifecycle events like BeforeInitialise and AfterInitialise, which can be used to execute specific tasks or set up event listeners in your services.

Usage

Here's an example of how to use @ts-phoenix/core, including all the features:

// defs.ts
export interface PackageConfigType {
  message: string;
  requiredField: string;
}

export type PackageRequiredConfigType = Pick<
  PackageConfigType,
  'requiredField'
>;
// config.ts
import { PackageConfigToken } from '@ts-phoenix/core';
import { PackageConfigType } from './defs';

export const MY_PACKAGE_CONFIG_TOKEN =
  new PackageConfigToken<PackageConfigType>('MY_PACKAGE');
// service.ts
import {
  CoreBeforeInitialiseEvent,
  CoreAfterInitialiseEvent,
  Injectable,
  InjectToken,
} from '@ts-phoenix/core';
import { EventManger } from '@ts-phoenix/event-manager';
import { PACKAGE_CONFIG_TOKEN } from './config';
import { PackageConfigType } from './defs';

@Injectable()
export class MyService {
  constructor(
    @Inject(EventManager) private readonly eventManager: EventManager,
    @InjectToken(PACKAGE_CONFIG_TOKEN)
    private readonly config: PackageConfigType,
  ) {
    this.eventManager.addEventListener({
      event: CoreBeforeInitialiseEvent,
      handler: () => console.log('Before initialising'),
    });

    this.eventManager.addEventListener({
      event: CoreAfterInitialiseEvent,
      handler: () => console.log('After initialising'),
    });
  }

  public showConfig() {
    console.log(this.config);
  }
}
// package.ts
import { Package, Injectable, createPackageDependency } from '@ts-phoenix/core';
import { MyService } from './service';
import { PackageConfigType, PackageRequiredConfigType } from './defs';
import { CONFIG_TOKEN } from './config';

@Injectable()
class MyPackage extends Package<Config, RequiredConfig> {
  public getConfigToken() {
    return CONFIG_TOKEN;
  }

  public getDependencies() {
    return [SomeOtherPackage];
  }

  public getDefaultConfig() {
    return {
      message: 'Hi', // you don't need to provide requiredField in the default config
    };
  }
}
// core.ts
import { Core } from '@ts-phoenix/core';
import { MyPackage } from './package';
import { MyService } from './service';

const core = new Core({
  packages: [
    new MyPackage({
      requiredField: ':D', // this is required; you can still override "message" too
    }),
  ],
});

core.initialise().then(() => {
  const myService = core.container.get(MyService);

  myService.showConfig(); // { message: "Hi", requiredField: ":D" }
});

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

GPL 3.0