{"size": 758, "ext": "js", "max_stars_repo_path": "scripts/push_hook.js", "max_stars_repo_name": "mbland/team-api-server", "max_stars_repo_stars_event_min_datetime": "2019-02-24T17:44:45.000Z", "max_stars_repo_stars_event_max_datetime": "2019-02-24T17:44:45.000Z", "max_issues_repo_path": "scripts/push_hook.js", "max_issues_repo_name": "mbland/team-api-server", "max_issues_repo_issues_event_min_datetime": "2015-11-12T16:40:12.000Z", "max_issues_repo_issues_event_max_datetime": "2016-06-02T18:46:35.000Z", "max_forks_repo_path": "scripts/push_hook.js", "max_forks_repo_name": "18F/team-api-server", "max_forks_repo_forks_event_min_datetime": "2016-02-22T17:53:26.000Z", "max_forks_repo_forks_event_max_datetime": "2021-02-14T11:28:12.000Z"}
{"max_stars_count": 1, "max_issues_count": 15, "max_forks_count": 4, "avg_line_length": 24.4516129032, "max_line_length": 66, "alphanum_fraction": 0.6715039578}
/**
 * Test script for locally sending a mock GitHub push webhook
 */

const crypto = require('crypto');

const rp = require('request-promise');
const env = require('../lib/env');

const payload = require('./push_payload.json');

const postOptions = {
  url: `http://localhost:${env.PORT}`,
  json: payload,
};

if (env.WEBHOOK_SECRET) {
  // If WEBHOOK_SECRET is present, then create a signature from it
  // and add it to the header of the mock push payload
  const signature = crypto.createHmac('sha1', env.WEBHOOK_SECRET)
    .update(JSON.stringify(payload))
    .digest('hex');
  postOptions.headers = {
    'X-Hub-Signature': `sha1=${signature}`,
  };
}

rp.post(postOptions).catch((err) => {
  console.error(`Error POSTing mock webhook: ${err}`);
});
