neotoma/sync-server

View on GitHub
app/lib/request.js

Summary

Maintainability
A
0 mins
Test Coverage
/**
 * Customized request module
 * @module
 */

var debug = require('app/lib/debug')('app:request');
var request = require('request');

request.statusCodeError = function(statusCode) {
  var error;
  debug('statusCode', statusCode);

  if ([200, 201, 202].indexOf(statusCode) === -1) {
    error = new Error(`Failed to make successful request. HTTP status code: ${statusCode}`);
  }

  return error;
};

module.exports = request;