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

@tenfold/http-client

Package Overview
Dependencies
Maintainers
8
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tenfold/http-client

Http Client for Tenfold projects

  • 1.0.0-alpha.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
26
decreased by-40.91%
Maintainers
8
Weekly downloads
 
Created
Source

Tenfold HTTP Client

This repo exports helper functions to help capture metrics for API requests.

Usage

import { getHttpClient, HttpClientOptions, TfHttpClient } from '@tenfold/http-client';

const opts: HttpClientOptions = { statsdConfig: ... }
const httpClient: TfHttpClient = getHttpClient(opts);

httpClient.post(...)

The HttpClientOptions interface for now only has one property: statsdConfig, which represents the configuration object for statsd. See the resources below for statsd docs.

Using the Tenfold Error Interceptor

On version v0.5.0 an error interceptor helper was added. The interceptor will handle Axios errors and convert them to Tenfold Api error format (see https://github.com/tenfold/tenfold-api-responses-ts). To use it, you need to:

import { getHttpClient, TfHttpClient, TfErrorHandler } from '@tenfold/http-client';

const httpClient: TfHttpClient = getHttpClient(opts);

httpClient.interceptors.response.use((response: AxiosResponse) => response, TfErrorHandler.createInterceptor(logger));

Where logger is an optional parameter to log errors.

Developing

  1. Clone the repo git clone git@github.com:tenfold/tenfold-types.git
  2. cd ./tenfold-types
  3. yarn install

The source files can be found on the packages/http-client/src folder and the tests can be found on the test folder. Make sure to add tests for all your changes. Also, make sure to create a branch from master to develop your changes. To run the tests you can simply use the command npm test. Once you're done with your changes, send a pull request to master and get reviews.

Generating a tag

OUTDATED - To be reviewed

  1. Once your changes are done (see Making Changes above) and merged to master, checkout master, go to the root of the project.
  2. To generate a tag use npm version major|minor|patch. This will automatically generate a tag following the [https://semver.org/](Semver versioning). You should use major for breaking changes, minor for new features and patch for bug fixes.
  3. The command above will generate a new tag and bump the version on package.json. You need to commit the changes to package.json and package-lock.json. So checkout a new branch, commit the bump and send a PR updating master

Bellow there's is a summary with the commands to implement the steps above:

git checkout master
git pull
npm version major | minor | patch
git checkout -b chore/bumping-version
git add package.json package-lock.json
git commit -m "Bumping version to vX.Y.Z"
git push

Resources

The exposed http client uses axios underneath. You can find axios documentation https://github.com/axios/axios. For the metrics part, the framework used is statsd. You can find more details about statsd https://www.npmjs.com/package/node-statsd.

Keywords

FAQs

Package last updated on 29 Jun 2021

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