Node.js - Reply to Instagram hub.challenge

Pretty new to Node.js. I'm working on a project where I need access to Instagram's subscription/streaming API. Stuck on the handshake authorization, where my server needs to reply with a challenge code sent by Instagram.

The code to get and log the challenge code:

var http = require('http'),
url = require ('url');

http.createServer(function (req, res) {
  var parts = url.parse(req.url, true);
  var parts = parts.query['hub.challenge'];
    console.log(parts);
}).listen(8080, '0.0.0.0');

And the code to send the subscribe request to Instagram:

Instagram = require('instagram-node-lib');

Instagram.set('client_id', 'myClientID');
Instagram.set('client_secret', 'myClientSecret');
Instagram.set('callback_url', 'http://www.myLocalTunnelAddress/callback.js')

Instagram.media.subscribe({ lat: 48.858844300000001, lng: 2.2943506, radius: 1000 });

I can get the challenge code from Instagram's GET request, but have been working at this for a while and haven't been able to send it back. Does anyone have a suggestions as to how to do this? Thank you!

Check out this node.js library

https://github.com/mckelvey/instagram-node-lib/blob/master/lib/class.instagram.subscriptions.js

and how he implemented his handshake method: https://github.com/mckelvey/instagram-node-lib/blob/master/lib/class.instagram.subscriptions.js