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

jira-node-client

v1.1.0

Published

provide tools to run jira rest api managing retries and multiple pages results

Downloads

9

Readme

jira-node-client - A node client to easily get data from Jira

Build Status Coverage Status Dependency Status Scrutinizer Code Quality

jira-node-client is a node module providing a function to easily get data from Jira with pages aggreation and retries features.

Features

  • executes provided Jira rest api and return response
  • if response includes several pages (total > maxResults) all pages optionally retrieved and aggregated in the response
  • In case of specific errors (5xx, ECONNRESET, ENOTCONN or if the body of the error is 'timeout exceeded'), several attempts are done with a timeout between each ones (5 attempts, 1 second timeout)

Installation

npm install jira-node-client

How to use?

First, make sure credentials are set as environment variables:

  • JIRA_USER
  • JIRA_PASSWORD
To check if credentials are set
const jira = require('jira-node-client');
jira.areJiraCredentialsMissing(); // returns true if any of the 2 credentials is not set

Authentication

Default behavior is basic authentication, meaning that user and password is set in the header of each request to Jira. But you can also enable cookie based authentication, meaning that a first login will retrieve a cookie that will be added to all further api calls. If you application runs long enough to reach cookie expiration, this is detected and a new cookie is automatically retrieved. This will so remain transparent. To enable cookie based authentication

const jira = require('jira-node-client');
jira.config.authentication = 'cookie'; // enable cookie based authentication
To get data
const jira = require('jira-node-client');
jira.execJiraQuery('https://www.myjirainstance.com/jira/rest/api/latest/search?jql=project = PROJKEY and issuetype not in (Epic,subTaskIssueTypes()) and resolution != Unresolved', true)
  .then((response) => { // response is the JSON object returned by the api
    let nbIssues = response.total;
    let firstIssueKey = response.issues[0].key;
  })
  .catch((error) => {
    // error is an object including 2 properties: code and message
  });

Note: Jira REST Apis and JSON format can be found at https://docs.atlassian.com/jira/REST/cloud/.

To configure

You can configure retry behavior

const jira = require('jira-node-client');
jira.config.maxRetry = 10 // On server errors, retries to execute the api 10 time; default is 5
jira.config.retryTimeout = 5000 // wait 5000ms between each retry; default is 1000ms

Running tests

To run the tests suite, first install devlopment dependencies:

npm install

Then run the tests:

npm test

To check code coverage, run:

npm run cover

To do

  • [x] provide function to check that credentials are set in environment
  • [ ] provide cookie based authentication
  • [ ] base url is configured once
  • [x] make timeout and number of retries configurable