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

@ecsbase/firebase

v1.0.0

Published

@ecsbase/firebase — reusable building block.

Readme

@ecsbase/firebase

Brand-agnostic Firebase Firestore toolkit: a typed DataService with retry, a pluggable read-through CacheDataService, a date-partitioned path helper, and an InjectionToken-based path registry for multi-project apps.

Works in both Angular 20 (DI) and plain Node.js (manual instantiation).

Install

pnpm add @ecsbase/firebase @angular/fire firebase

Peer dependencies

  • @angular/common ^20.0.0
  • @angular/core ^20.0.0
  • @angular/fire ^20.0.0
  • @ecsbase/utils workspace:*
  • firebase ^11.0.0

Quick start — Angular

import { ApplicationConfig } from '@angular/core';
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
import { getFirestore } from 'firebase/firestore';
import {
  provideEcsbaseFirestore,
  provideFirestorePaths,
  provideCacheAdapter,
  DataService,
  CacheDataService,
} from '@ecsbase/firebase';
import { IndexedDbCacheAdapter } from '@ecsbase/firebase/indexeddb';

export const appConfig: ApplicationConfig = {
  providers: [
    provideFirebaseApp(() => initializeApp({ /* config */ })),
    // Register Firestore under the brand-agnostic ECSBASE_FIRESTORE token.
    // Do NOT use @angular/fire's `provideFirestore()` here — its `Firestore`
    // class identity differs from `firebase/firestore`'s, breaking DataService DI.
    provideEcsbaseFirestore(() => getFirestore()),
    provideFirestorePaths({
      clients: 'clients',
      orders: 'tenants/{tid}/orders',
    }),
    provideCacheAdapter(() => new IndexedDbCacheAdapter()),
  ],
};

// Anywhere
constructor(
  private data: DataService,
  private cached: CacheDataService,
) {}

await this.data.list('clients');
await this.cached.read('clients/abc', 60_000);

Quick start — Node.js

import { initializeApp } from 'firebase/app';
import { getFirestore } from 'firebase/firestore';
import { DataService, CacheDataService, InMemoryCacheAdapter } from '@ecsbase/firebase';

const app = initializeApp({
  /* config */
});
const data = DataService.create(getFirestore(app));
const cached = CacheDataService.create(data, new InMemoryCacheAdapter());

await data.list('clients');

Cache adapters

  • InMemoryCacheAdapter — default; Node/browser/SSR safe
  • IndexedDbCacheAdapter — browser-only, persistent (import from @ecsbase/firebase/indexeddb)
  • Implement CacheAdapter for custom storage (Redis, file, etc.)

Models

All read / list results carry id and path automatically. Define your Firestore models against the exported dbObject base type so updates and deletes can use the document's own path:

import type { dbObject } from '@ecsbase/firebase';

export class Client implements dbObject {
  id = '';
  path = '';
  name = '';
}

DataService.read<T> and DataService.list<T> default T to dbObject, so omitting the explicit type still yields { id, path } on every record.

Multi-project

Use DataServiceFactory when one app talks to multiple Firestore instances:

import { provideDataServices, DataServiceFactory } from '@ecsbase/firebase';

providers: [provideDataServices({ tenant: tenantFs, shared: sharedFs })];

// ...
constructor(f: DataServiceFactory) {
  f.for('tenant').read('clients/abc');
  f.forCached('shared').list('catalog');
}

Date-partitioned paths

import { buildDayPath, buildMonthPath } from '@ecsbase/firebase';

buildDayPath('events', Date.now()); // 'events/2026/05/21' (UTC)
buildMonthPath('logs', Date.now(), 'America/New_York');

API

  • DataServiceread, list, create, set, update, delete, batchSet, resolvePath
  • CacheDataService — same surface plus TTL, invalidate, invalidatePrefix
  • CacheMetricsService — signals: hits, misses, writes, hitRate
  • dbObject — base type for Firestore models (id, path)
  • provideFirestorePaths, FIRESTORE_PATHS
  • provideCacheAdapter, CACHE_ADAPTER, InMemoryCacheAdapter
  • provideDataService, DATA_SERVICE_CONFIG — retry tuning
  • provideDataServices, DataServiceFactory — multi-project
  • buildDayPath, buildMonthPath, buildYearPath, DatePathFormatter

Inputs / Outputs

| Name | Type | Default | Description | | ---- | ---- | ------- | ----------- |

Playground

Live demos:

Run pnpm start:playground then visit http://localhost:4200/firebase.

License

MIT — see LICENSE at the repository root.