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

@cbm-common/client-branch-repository

v0.0.1

Published

Documentación técnica y guía rápida para la librería `client-branch-repository` del mono-repo.

Readme

client-branch-repository

Documentación técnica y guía rápida para la librería client-branch-repository del mono-repo.

Objetivo

Esta librería encapsula las operaciones HTTP relacionadas con las "client branches" (ramas de cliente). Proporciona:

  • Un módulo configurable (CbmClientBranchModule.forRoot({ baseUrl })) para inyectar la URL base de la API.
  • Un HttpService extendido que permite registrar interceptores locales (CLIENT_BRANCH_HTTP_INTERCEPTORS).
  • Un servicio (CbmClientBranchService) que construye y ejecuta las llamadas HTTP.
  • Un repositorio (CbmClientBranchRepository) que expone la API para consumo por la aplicación.

El diseño replica el patrón usado por user-repository y otras librerías del repositorio, para mantener coherencia en la configuración, inyección y uso de interceptores.

Instalación e importación

Importar y configurar el módulo en el AppModule o en el módulo de la feature:

import { CbmClientBranchModule } from '@mf-cbm-common/client-branch-repository';

@NgModule({
   imports: [
      CbmClientBranchModule.forRoot({ baseUrl: 'https://api.example.com/client-branch' }),
   ],
})
export class AppModule {}

La llamada a forRoot inyecta internamente el token CLIENT_BRANCH_MODULE_CONFIG con la configuración proporcionada.

Archivos relevantes y responsabilidades

  • client-branch.module.ts

    • Define la interfaz ICbmClientBranchModuleConfig y el token CLIENT_BRANCH_MODULE_CONFIG.
    • Expone forRoot(config) para inyectar configuración.
  • http.service.ts

    • Declara CLIENT_BRANCH_HTTP_INTERCEPTORS (InjectionToken).
    • ClientBranchHttpService extiende HttpClient y arma una cadena de interceptores registrada bajo el token.
    • ClientBranchAuthInterceptor (stub) incluido como ejemplo; puedes reemplazarlo o extenderlo para añadir headers/auth.
  • client-branch.service.ts

    • Servicio que depende de HttpClient y del token CLIENT_BRANCH_MODULE_CONFIG para componer URLs.
    • Método list(params) de ejemplo que usa config.baseUrl.
  • client-branch.repository.ts

    • Repositorio que delega en el servicio, expuesto para el consumo de la app.

API pública (ejemplos de uso)

Inyecta el repositorio y usa sus métodos:

import { Component } from '@angular/core';
import { CbmClientBranchRepository } from '@mf-cbm-common/client-branch-repository';

@Component({ selector: 'app-sample', template: '' })
export class SampleComponent {
   constructor(private repo: CbmClientBranchRepository) {}

   fetch() {
      this.repo.list({ page: 1 }).subscribe({
         next: res => console.log('OK', res),
         error: err => console.error('ERR', err),
      });
   }
}

CbmClientBranchService expone métodos que retornan Observable<T> y el repositorio simplemente delega.

Interceptores y personalización

La librería permite registrar interceptores específicos usando el token CLIENT_BRANCH_HTTP_INTERCEPTORS.

Ejemplo de registro (en el módulo de la app):

import { CLIENT_BRANCH_HTTP_INTERCEPTORS } from '@mf-cbm-common/client-branch-repository';

providers: [
   { provide: CLIENT_BRANCH_HTTP_INTERCEPTORS, useClass: MyAuthInterceptor, multi: true },
]

El ClientBranchHttpService montará la cadena de interceptores y la usará para las peticiones realizadas a través de él.

Desarrollo y build

Compilar localmente:

# desde la raíz del repo
ng build client-branch-repository

Publicar (si aplica):

cd dist/client-branch-repository
npm publish

Buenas prácticas y notas

  • Mantén baseUrl conciso (sin trailing slash) y construye rutas relativas en CbmClientBranchService si necesitas endpoints adicionales.
  • Usa interceptores para cross-cutting concerns (auth, logging, transformaciones de respuesta).
  • Si necesitas configuración más avanzada (por ejemplo carga asíncrona de configuración), puedo añadir forRootAsync.

Soporte y siguientes pasos sugeridos

  • Puedo adaptar forRoot para que, además de inyectar el token, registre ClientBranchHttpService e interceptores por defecto si lo prefieres.
  • Puedo añadir ejemplos de testing unitario para CbmClientBranchService y ClientBranchHttpService.

Si quieres que haga alguno de los pasos anteriores ahora (p. ej. ng build o añadir forRoot que registre providers), indícalo y lo realizo.