0.0.1 • Published 2 years ago

@govuk-one-login/frontend-passthrough-headers v0.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Coverage

@govuk-one-login/frontend-passthrough-headers

Purpose

@govuk-one-login/frontend-passthrough-headers is a set of functions to extract pass-through headers that should be passed through our frontends to our backends.

Table of Contents

  1. Installation
  2. How to use
  3. Issues

Installation

Add to your project using npm i @govuk-one-login/frontend-passthrough-headers

How to use

createPersonalDataHeaders

!WARNING This function extracts headers that contain Personal Data. It must not be passed through to API calls to external services.

Optional: Logger Configuration

The frontend-passthrough-headers library allows you to set a custom logger or use the default pino logger.

Setting a Custom Logger

Use the setCustomLogger function to configure a custom logger. The custom logger must implement the following interface:

export type CustomLogger = {
  trace: (message: string) => void;
  warn: (message: string) => void;
};

Example:

import { setCustomLogger } from "@govuk-one-login/frontend-passthrough-headers";

const customLogger = {
  trace: (message: string) => console.log(`TRACE: ${message}`),
  warn: (message: string) => console.warn(`WARN: ${message}`),
};

setCustomLogger(customLogger);

Default Logger

If no custom logger is set, a pino logger is used with: • Name: @govuk-one-login/frontend-passthrough-headers • Log Level: process.env.LOG_LEVEL or process.env.LOGS_LEVEL (defaults to warn).

By default, the logger is initialised only once, and calling setCustomLogger again will log a warning.

Issues

Please raise any issues on the GitHub repo.

1.2.0

1 year ago

1.3.0

10 months ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago