🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

@companieshouse/api-sdk-node

Package Overview
Dependencies
Maintainers
2
Versions
425
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@companieshouse/api-sdk-node

This SDK abstract the calls to our public APIs.

npmnpm
Version
1.0.1
Version published
Weekly downloads
2.6K
-37.25%
Maintainers
2
Weekly downloads
 
Created
Source

Companies House SDK (Node)

This SDK abstract the calls to our public APIs.

Quick start

Use NPM to install the SDK in your project;

npm i @companieshouse/api-sdk-node

Note that this install may need to be run with the 'sudo' command to avoid an error related to file permissions (and Sophos virus scanning).

The following snippet shows how to get up and running quickly using TypeScript.


import {createApiClient} from "@companieshouse/api-sdk-node";

(async () => {
    const api = createApiClient("your-api-key");
    const profile = await api.companyProfile.getCompanyProfile("00006400");

    console.log(profile);
})()

There is an alternative way of calling some of the services, which forces you to check for errors. It borrows concepts from the Either class found in functional programming.


import {createApiClient} from "@companieshouse/api-sdk-node";

(async () => {
    const api = createApiClient("your-api-key");
    const orderResult = await api.companyProfile.getOrder("an-existing-order-id");

    if(orderResult.isFailure()) {
        const errorResponse = orderResult.value;
        console.log(errorResponse);
    } else {
        const order = orderResult.value;
        console.log(order);
    }
    
})()

Development

To test the changes made to this sdk inside your project, you can use npm link.

From within this directory, run the following command to make symbolic links to it within the global node modules directory.

npm link

Then from within your local project, simply link it with the following command

npm link api-sdk-node

Note that if your local project is running within a Vagrant Virtual Machine, this command will need to be run on the VM.

Testing

Jest is the framework used in this project and all tests can be run using npm.

npm t

To tun the tests with coverage, pass the --coverage flag on the command line.

npm t -- --coverage

FAQs

Package last updated on 13 Oct 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