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

@mojaloop/participants-bc-client-lib

v0.6.4

Published

Participants BC - Client

Downloads

122

Readme

Mojaloop vNext Participants Client Library

Git Commit Git Releases Npm Version NPM Vulnerabilities CircleCI

This is a readonly HTTP client library for the Participants bounded context.

It allows for the following readonly operations:

  • getAllParticipants: get all registered participants.
  • getParticipantsByIds: get multiple participants whose ids match the provided array of Ids.
  • getParticipantById: get a single participant by its Id.
  • getParticipantAccountsById: get the account list of a participant by its Id (This is the only call that includes balances - fetched from the Accounts and Balances Services by the Participants Service).

NOTE: This client requires an instance of a IAuthenticatedHttpRequester with adequate credentials from the Authentication BC to be passed in the constructor

Install

npm install @mojaloop/participants-bc-client-lib

Usage

Configure

"use strict";

import {ILogger, ConsoleLogger} from "@mojaloop/logging-bc-public-types-lib";
import {
	AuthenticatedHttpRequester,
	IAuthenticatedHttpRequester
} from "@mojaloop/security-bc-client-lib";
import {
    AccountsAndBalancesClient,
    IAccountDTO,
    IJournalEntryDTO
} from "@mojaloop/participants-bc-client-lib";

const logger: ILogger = new ConsoleLogger();

// IAuthenticatedHttpRequester consts
const AUTH_TOKEN_ENPOINT = "http://localhost:3201/token";
const USERNAME = "user";                // only needed for user logins (password grant)
const PASSWORD = "superPass";           // only needed for user logins (password grant)
const CLIENT_ID = "security-bc-ui";     // always required
const CLIENT_SECRET = "client_secret";  // only needed for app logins (client_credentials grant)

// create the instance of IAuthenticatedHttpRequester
const authRequester = new AuthenticatedHttpRequester(logger, AUTH_TOKEN_ENPOINT);

// set user credentials example (password grant)
authRequester.setUserCredentials(CLIENT_ID, USERNAME, PASSWORD);

// set app credentials example (client_credentials grant)
// authRequester.setAppCredentials(CLIENT_ID, CLIENT_SECRET);

// ParticipantsHttpClient constants
const PARTICIPANTS_BASE_URL: string = "http://localhost:3010";
const HTTP_CLIENT_TIMEOUT_MS: number = 10_000;

const participantsClient = new ParticipantsHttpClient(logger, PARTICIPANTS_BASE_URL, authRequester);

await participantsClient.getAllParticipants().then(value => {
	console.log(value);
}).catch(reason => {
	if(reason instanceof UnauthorizedError){
		console.log("Invalid credentials");
	}else if(reason instanceof ConnectionRefusedError){
		console.log("Cannot connect to destination endpoint");
	}else if(reason instanceof RequestTimeoutError) {
		console.log("Timeout while waiting for request to finish");
	}else if(reason instanceof MaxRetriesReachedError) {
		console.log("Request max retries reached, giving up");
	}else {
		console.error(reason);
	}
});

See Also