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

@govuk-pay/request

Package Overview
Dependencies
Maintainers
9
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@govuk-pay/request

Simple HTTP client for internal GOV.UK Pay services.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
9
Created
Source

Pay request 🌐

Build Status Known Vulnerabilities

Simple HTTP client for internal GOV.UK Pay services.

Provides a consistent request language across disparate backend route styles.

import { Ledger } from '@govuk-pay/request'

const payments = await Ledger.payments.list()

Usage

Request language

retrieve(id)

Get one entity details.

const payments = await Ledger.payments.retrieve('ofd7t9jbsq844rlv3agthdu9am')

list()

List all entities, these resources usually support paginiation and filters.

const payments = await Ledger.payments.list({
    card_brand: CardBrand.Visa
})

update(id, params)

Update an entity with supported request params.

await AdminUsers.users.update('user-id', {
    disabled: false
})

delete(id)

Delete entity.

await PublicAuth.tokens.delete({ token_link: 'token-id' })

Configuration

Pay request exposes a top level config() method. By default the library will use process.env to check for URLs that map to clients.

These URLs can also overriden with the config() method.

import { config } from '@govuk-pay/request'

config({
    CONNECTOR_URL: 'https://custom.digital/'
})

Pay request also supports hooks into the request lifecycle for logging and custom headers.

config(process.env, {
    failureResponse: (context) => { console.log(`Request from ${context.service} failed with ${context.code}`) },
    successResponse: (context) => { console.log(`Request from ${context.service} returned in ${context.responseTime}`) },
    transformRequestAddHeaders: () => ({
        'x-request-id': 'correlation-id'
    })
})

Service data structure

Type definitions are provided for all requests, responses and entities served by backend resources.

Experimental

OpenAPI is used to generate type shape structures for each of the clients based on .json specification for that service.

For any internal service that doesn't have full annotations for OpenAPI there are services/${client}/types.ts polyfill definitions to provide a uniform developer experience.

FAQs

Package last updated on 16 Jul 2020

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