Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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

Package Overview
Dependencies
Maintainers
16
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

This package provides tools to define FT app context data and a [JSON schema] definition to validate it with.

  • 0.1.3
  • npm
  • Socket score

Version published
Weekly downloads
100
decreased by-86.77%
Maintainers
16
Weekly downloads
 
Created
Source

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

This package provides tools to define FT app context data and a JSON schema definition to validate it with.

Getting started

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

npm install -S @financial-times/dotcom-server-app-context

This package provides a single class which can be configured using options:

import { AppContext } from '@financial-times/dotcom-server-app-context'
const appContext = new AppContext()

The app context instance provides methods to get, set, and validate context data:

appContext.set('appName', 'my-application')
const property = appContext.get('appName') // "my-application"

try {
  appContext.validate()
} catch (error) {
  console.error('Application context data is invalid:', error)
}

API

get(property: string): any

Returns the value of the requested property.

set(property: string, value: any)

Sets the value of the specified property.

validate(): boolean

Validates the current data against the schema definition. If the data is invalid this method will throw an error with details of the first error encountered.

Options

The AppContext class accepts the following parameters. All parameters are optional:

context

An app context data object, see app context data for more information. Defaults to {}.

App Context Data

Please refer to the JSON schema definition for more information.

FAQs

Package last updated on 09 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc