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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@govuk-pay/request

v1.0.0

Published

Simple HTTP client for internal GOV.UK Pay services.

Downloads

12

Readme

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.