<commit_before>'use strict';

var $http = require('request'),
    $q = require('q'),
    token = require('../services/instagram/token');

function search(req, res) {
    var _req;

    if (req.query && req.query.q) {
        token.check()
            .then(function (_token) {
                _req = $http
                    .get({
                        url: 'https://api.instagram.com/v1/tags/' + req.query.q + '/media/recent?' + _token
                    })
                    .on('error', function () {
                        token.refresh();
                        res.status(404).end();
                    })
                    .pipe(res);
            })
            .catch(function () {
                res.status(404).end();
            });
    } else {
        res.status(404).end(process.env.INSTAGRAM_ID + ' '+ process.env.INSTAGRAM_PASS);
    }

    res.on('close', function () {
        if (_req && typeof _req.destroy === 'function') {
            _req.destroy();
        }
    });

}

module.exports = {
    search: search
};<commit_msg>test instagram server side<commit_after>'use strict';

var $http = require('request'),
    $q = require('q'),
    token = require('../services/instagram/token');

function search(req, res) {
    var _req;

    if (req.query && req.query.q) {
        token.check()
            .then(function (_token) {
                _req = $http
                    .get({
                        url: 'https://api.instagram.com/v1/tags/' + req.query.q + '/media/recent?' + _token
                    })
                    .on('error', function () {
                        token.refresh();
                        res.status(404).end();
                    })
                    .pipe(res);
            })
            .catch(function () {
                res.status(404).end();
            });
    } else {
        res.status(404).end();
    }

    res.on('close', function () {
        if (_req && typeof _req.destroy === 'function') {
            _req.destroy();
        }
    });

}

module.exports = {
    search: search
};
{'fraction_non_alphanumeric': 0.163855421686747, 'fraction_numerical': 0.00963855421686747, 'mean_word_length': 1.2565217391304349, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6638103', 'n_tokens_mistral': 618, 'n_tokens_neox': 576, 'n_words': 100}