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/reason-country-repository

v0.0.2

Published

This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.1.0.

Downloads

11

Readme

ReasonCountry

This project was generated using Angular CLI version 20.1.0.

Code scaffolding

Angular CLI includes powerful code scaffolding tools. To generate a new component, run:

ng generate component component-name

For a complete list of available schematics (such as components, directives, or pipes), run:

ng generate --help

Building

To build the library, run:

ng build reason-country-repository

This command will compile your project, and the build artifacts will be placed in the dist/ directory.

Publishing the Library

Once the project is built, you can publish your library by following these steps:

  1. Navigate to the dist directory:

    cd dist/reason-country-repository
  2. Run the npm publish command to publish your library to the npm registry:

    npm publish

Running unit tests

To execute unit tests with the Karma test runner, use the following command:

ng test

Running end-to-end tests

For end-to-end (e2e) testing, run:

# reason-country-repository

Librería Angular que provee el servicio y repositorio para gestionar los motivos (reason) asociados a códigos de país.

Esta documentación está en español y cubre configuración, uso y métodos principales expuestos por la librería.

## Objetivo

Proveer una capa reutilizable para acceder a los endpoints REST relacionados con "reason-country" desde aplicaciones que consumen este paquete.

La librería expone:
- Un token de configuración `REASON_COUNTRY_MODULE_CONFIG` y la interfaz `ICbmReasonCountryModuleConfig` (campo principal: `baseUrl`).
- Un módulo `CbmReasonCountryModule` que se registra con `forRoot(config)` (patrón minimalista).
- Un servicio `CbmReasonCountryService` que realiza las llamadas HTTP.
- Un repositorio `CbmReasonCountryRepository` (wrapper orientado a la app) que delega al servicio.

## Instalación (en la aplicación consumidora)

1. Construye la librería en el monorepo si trabajas localmente:

```bash
ng build reason-country-repository
  1. En tu aplicación Angular, importa y configura el módulo en el AppModule o módulo raíz donde quieras registrar la URL base:
import { CbmReasonCountryModule } from 'reason-country-repository';

@NgModule({
   imports: [
      // ...
      CbmReasonCountryModule.forRoot({ baseUrl: 'https://api.tu-dominio.com/reason-country' }),
   ],
})
export class AppModule {}

Nota: el patrón forRoot aquí devuelve únicamente el Provider de configuración (igual que el patrón usado en user-repository). Si tu app necesita interceptores o providers adicionales, debes registrarlos explícitamente en tu módulo de aplicación.

Configuración

Interfaz de configuración:

export interface ICbmReasonCountryModuleConfig {
   baseUrl: string; // URL base del servicio REST (sin slash final preferible)
}

export const REASON_COUNTRY_MODULE_CONFIG = new InjectionToken<ICbmReasonCountryModuleConfig>('REASON_COUNTRY_MODULE_CONFIG');

La librería utiliza config.baseUrl para construir las rutas de cada endpoint.

Uso del servicio y repositorio

Inyecta el repositorio o el servicio en tus componentes o servicios:

import { Component } from '@angular/core';
import { CbmReasonCountryRepository } from 'reason-country-repository';

@Component({ /* ... */ })
export class MiComponente {
   constructor(private repo: CbmReasonCountryRepository) {}

   async cargarListado() {
      const res = await this.repo.list({ /* params */ }).toPromise();
      console.log(res);
   }
}

O usando directamente el servicio:

import { CbmReasonCountryService } from 'reason-country-repository';

constructor(private svc: CbmReasonCountryService) {}

this.svc.getOne('id').subscribe(resp => console.log(resp));

Métodos expuestos (resumen)

Los nombres y contratos están definidos en reason-country.model.

  • list(params): Observable
  • save(data): Observable
  • update(id, data): Observable
  • getOne(id): Observable
  • delete(id): Observable
  • restore(id): Observable
  • changeStatus(id, data): Observable

Revisa src/lib/reason-country.model.ts para ver las formas exactas de ListParams, SaveBody, UpdateBody, ChangeStatusBody y los tipos de respuesta.

Buenas prácticas

  • Asegura que baseUrl apunte al prefijo correcto del API (por ejemplo: https://api.example.com/reason-country).
  • Preferir inyectar el repositorio (CbmReasonCountryRepository) en componentes para mantener una capa de abstracción más estable entre la UI y el servicio HTTP.
  • Construye pruebas unitarias para el repositorio usando HttpClientTestingModule y mocks del REASON_COUNTRY_MODULE_CONFIG.

Tests

Para ejecutar tests del workspace (Karma/Jasmine o el runner configurado):

ng test

Build y publicación

Construye la librería antes de publicar:

ng build reason-country-repository

Los artefactos se generan en dist/reason-country-repository. Para publicar (si aplica):

cd dist/reason-country-repository
npm publish

Desarrollo local y resolución de tipos

En un monorepo, muchas aplicaciones consumen la librería mediante los paths de TypeScript configurados por Angular CLI. Si ves errores de resolución de tipos en la app, compila primero la librería con ng build para que dist/ contenga los paquetes consumibles.

Notas de migración

  • Esta librería sigue el patrón minimalista de configuración (token + forRoot returning Provider) para facilitar la composición en aplicaciones que usan múltiples librerías similares (ej.: user-repository).
  • Si antes forRoot registraba interceptores o providers adicionales y tu app dependía de ellos, vuelve a registrarlos en el módulo raíz de la aplicación o amplía forRoot localmente según tus necesidades.

Contacto

Para dudas sobre la implementación dentro del monorepo, revisa otros repositorios análogos como user-repository para seguir el mismo patrón y ejemplos.


Documento generado automáticamente por la plantilla del monorepo. Modifica según conveniencia.