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

@topcoder-platform/topcoder-bus-api-wrapper

v1.2.0

Published

Wrapper for Topcoder Bus API

Downloads

23

Readme

tc-bus-api-wrapper

Wrapper library for Topcoder Bus API

How to use this Wrapper

  1. Include the wrapper in package.json as follows
"tc-bus-api-wrapper": "topcoder-platform/tc-bus-api-wrapper.git"
  1. Create an instance of this wrapper with the configuration variables listed below
const busApi = require('tc-bus-api-wrapper')
const busApiClient = busApi(_.pick(config,
      ['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME',
        'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET', 'BUSAPI_URL',
        'KAFKA_ERROR_TOPIC', 'AUTH0_PROXY_SERVER_URL']))

Configuration / Environment variables:

  • Auth0 related variables

    • AUTH0_URL
    • AUTH0_AUDIENCE
    • TOKEN_CACHE_TIME (optional)
    • AUTH0_CLIENT_ID
  • BUSAPI_URL - Bus API URL. E.g. https://api.topcoder-dev.com/v5

  • KAFKA_ERROR_TOPIC - Error topic in Kafka to which error message need to be posted

  1. Every function in this wrapper will return a promise, Handling promises is at the caller end. Call the functions with appropriate arguments

E.g.

busApiClient
  .getTopics()
  .then(result => console.log(result.body, result.status))
  .catch(err => console.log(err))

await busApiClient.postEvent(reqBody)

Refer index.js for the list of available wrapper functions

Documentation for Bus API wrapper methods

All URIs are relative to BUSAPI_URL configuration variable.

Method | HTTP request | Description ------------- | ------------- | ------------- postEvent | POST /bus/events | Post event to the message bus. postError | POST /bus/events | Post error event to the message bus. This method is same as postEvent except that topic will be set by the wrapper itself. getHealth | GET /bus/health | Check API is healthy. headHealth | HEAD /bus/health | Get only response status and headers information but no response body for the endpoint. clearPlaceholdersCache | DELETE /bus/placeholders | Clear placeholders cache. createService | POST /bus/services | Create a service. createServicePayload | POST /bus/services/{serviceName}/payloads | Create the service payload. deleteService | DELETE /bus/services/{serviceName} | Delete the service. deleteServicePayload | DELETE /bus/services/{serviceName}/payloads/{payloadName} | Delete the service payload. getService | GET /bus/services/{serviceName} | Get the service. getServicePayload | GET /bus/services/{serviceName}/payloads/{payloadName} | Get the service payload. getServicePayloads | GET /bus/services/{serviceName}/payloads | Search the service payloads. getServices | GET /bus/services | Get all services. headService | HEAD /bus/services/{serviceName} | Get only response status and headers information but no response body for the endpoint. headServicePayload | HEAD /bus/services/{serviceName}/payloads/{payloadName} | Get only response status and headers information but no response body for the endpoint. headServicePayloads | HEAD /bus/services/{serviceName}/payloads | Get only response status and headers information but no response body for the endpoint. headServices | HEAD /bus/services | Get only response status and headers information but no response body for the endpoint. patchService | PATCH /bus/services/{serviceName} | Partially update the service. patchServicePayload | PATCH /bus/services/{serviceName}/payloads/{payloadName} | Partially update the payload. updateService | PUT /bus/services/{serviceName} | Update the service. updateServicePayload | PUT /bus/services/{serviceName}/payloads/{payloadName} | Update the service payload. getTopics | GET /bus/topics | Get topics. headTopics | HEAD /bus/topics | Get only response status and headers information but no response body for the endpoint.

Authorization

Bus API wrapper internally generates a JWT token using Auth0 credentials and pass it in the Authorization header.

Running tests

Following environment variables need to be set up before running the tests

- TEST_AUTH0_URL
- TEST_AUTH0_AUDIENCE
- TEST_AUTH0_CLIENT_ID
- TEST_AUTH0_CLIENT_SECRET
- TEST_BUS_API_URL
- TEST_KAFKA_ERROR_TOPIC

Refer to Step # 2 in this section to learn more about the configuration variables.

To run the tests alone, execute the command

npm run test

To run tests with coverage report, execute the command

npm run cov