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

bffconductor

v1.0.0

Published

Angular client library for the [BFFConductor](https://www.nuget.org/packages/BFFConductor) .NET pattern. Reads the `x-handle-message-as` response header and routes errors to the correct UI handler — toast, inline validation, modal, redirect, etc. — based

Downloads

207

Readme

bffconductor

Angular client library for the BFFConductor .NET pattern. Reads the x-handle-message-as response header and routes errors to the correct UI handler — toast, inline validation, modal, redirect, etc. — based on what the server specifies.


Companion Package

The server-side NuGet package is available at nuget.org/packages/BFFConductor. It sets the x-handle-message-as header and standardizes the ApiResponse envelope that this library consumes.

dotnet add package BFFConductor

Installation

npm install bffconductor

Quick Start

1. Register the interceptor in app.config.ts

import { bffResponseInterceptor, BFF_ERROR_ROUTER } from 'bffconductor';
import { provideHttpClient, withInterceptors } from '@angular/common/http';

export const appConfig: ApplicationConfig = {
  providers: [
    provideHttpClient(withInterceptors([bffResponseInterceptor])),
    { provide: BFF_ERROR_ROUTER, useClass: AppErrorRouter }
  ]
};

2. Implement BffErrorRouter

import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { BffErrorRouter, ApiError } from 'bffconductor';

@Injectable({ providedIn: 'root' })
export class AppErrorRouter implements BffErrorRouter {
  constructor(private router: Router) {}

  route(displayMode: string, errors: ApiError[], headers: Record<string, string>): void {
    const message = errors[0]?.message ?? 'An error occurred.';

    switch (displayMode) {
      case 'toast':
        // e.g. this.toastService.show(message);
        break;
      case 'inline':
        // e.g. this.formErrorService.set(errors);
        break;
      case 'modal':
        // e.g. this.dialogService.open(message);
        break;
      case 'redirect':
        this.router.navigateByUrl(headers['x-redirect-url'] ?? '/error');
        break;
      case 'silent':
        break;
    }
  }
}

How It Works

The bffResponseInterceptor hooks into Angular's HttpClient pipeline and does two things:

On success — unwraps the ApiResponse<T> envelope so your services receive data directly, not the wrapper object.

On error — reads the x-handle-message-as response header, then calls BffErrorRouter.route() with the display mode, errors array, and all response headers. Your router implementation decides how to present it.

HTTP error response
  └─ x-handle-message-as: inline
  └─ body: { success: false, errors: [{ message: "Name is required", code: "VALIDATION_FAILED" }] }
        ↓
  bffResponseInterceptor
        ↓
  BffErrorRouter.route("inline", errors, headers)
        ↓
  Your UI logic (show inline validation, toast, redirect, etc.)

If no BFF_ERROR_ROUTER is provided, the interceptor still processes responses but skips routing — errors are re-thrown for your own catchError handling.


API Reference

bffResponseInterceptor

HttpInterceptorFn — register via withInterceptors([bffResponseInterceptor]).

BFF_ERROR_ROUTER

InjectionToken<BffErrorRouter> — provide your implementation to handle routed errors.

BffErrorRouter

interface BffErrorRouter {
  route(displayMode: string, errors: ApiError[], headers: Record<string, string>): void;
}

ApiResponse<T>

interface ApiResponse<T> {
  success: boolean;
  data: T | null;
  errors: ApiError[];
}

ApiError

interface ApiError {
  message: string;
  code?: string;
}

BFF_DISPLAY_MODE_HEADER

String constant: 'x-handle-message-as'


Display Modes

Display modes are open strings — you define what they mean in your BffErrorRouter. Common conventions from the server-side library:

| Mode | Typical UI behaviour | |---|---| | silent | Suppress UI; handle programmatically | | toast | Brief auto-dismissing notification | | snackbar | Bottom-of-screen notification bar | | inline | Validation errors next to form fields | | modal | Blocking dialog | | page | Full-page error | | redirect | Navigate away (check x-redirect-url header) |