@financial-times/dotcom-middleware-app-context
TypeScript icon, indicating that this package has built-in type declarations

11.2.1 • Public • Published

@financial-times/dotcom-middleware-app-context

This package provides an Express compatible middleware which appends an instance of app context to each request and configures it with details automatically inferred from the running application.

Getting started

This package is compatible with Node 12+ and is distributed on npm.

npm install --save @financial-times/dotcom-middleware-app-context

After installing the package create a new instance of the middleware and register it with your application. The middleware can be configured with several options:

const express = require('express')
const app = express()

+const appContext = require('@financial-times/dotcom-middleware-app-context')
+app.use(appContext.init())

Once registered an appContext property will be added to the response locals:

app.get('/', (request, response) => {
  const appContextData = response.locals.appContext.getAll()
})

See the app context package documentation for more information.

Options

The middleware accepts the following parameters:

appContext

An app context data object, see the app context schema for more information. This can be used to append extra properties or override any of the properties automatically inferred from the running application.

Readme

Keywords

none

Package Sidebar

Install

npm i @financial-times/dotcom-middleware-app-context

Weekly Downloads

230

Version

11.2.1

License

MIT

Unpacked Size

168 kB

Total Files

7

Last publish

Collaborators

  • robgodfrey
  • robertboulton
  • seraph2000
  • hamza.samih
  • notlee
  • emmalewis
  • aendra
  • the-ft
  • rowanmanning
  • chee
  • alexwilson