Recently a need arose to generate project reports rapidly for clients, listing outstanding and recently completed tickets. These tickets are maintained through our issue tracking system, JIRA, which has an impressively robust API for interfacing with third-party applications. Using Node in conjunction with the Express JavaScript web application framework I’ve put together a small application prototype for rapidly generating reports for our clients.

For those new to Node, I urge you to follow the fantastic tutorials at NodeSchool.io. Most essentially, their introductory Node tutorial, Scope and Closures tutorial, and Express tutorial.

The initial step to put together this prototype, after installing Express and generating the application skeleton, was to add the node-jira NPM module to the project. This is an object-oriented wrapper for the JIRA REST API that abstracts away the rudimentary REST details, such as piecing together our requests into a URL format for the JIRA API. With that installed, through Bower I pulled down the Bootstrap-Sass library and added ‘app.use(‘/bower_components’, express.static(__dirname + ‘/bower_components’));’ in the app.js file to instruct Express to include the Bower libraries. Together development was now ready to begin.

As is common in MVC, MV*, and other frameworks, Express uses routes to respond to client requests. A route is a combination of the request URL, the request method (GET/POST), and a function to execute upon receiving the request. I created three routes: a default GET route for the homepage that renders a login page for users to enter their JIRA instance URL (ie. acorso.jira.com), their username, and their password; a project selection POST route that consumes the submitted login information and renders a list of available projects within the specified JIRA instance; and a third, GET route, to generate the ticket report.

When credentials are submitted through the homepage, a new JIRA object is created utilizing the node-jira module. This object is then used to execute several API calls. First, upon logging in, a list of projects is called for and then sent to an EJS template where they are rendered. Once a project is selected, an asynchronous function is called, where a few more API calls are made and then data restructured, commencing with a report generated for the user.

This was a fun prototype to throw together and with the initial concept implemented I plan on modernizing the front-end with Angular to avoid full page reloads and securing the sign-in process. The code will be added to my Github account in the coming days.

JIRA Automated Testing Screen