<commit_before>var restify = require('restify');
var logger = require('./logger/logger').logger;

var acceptParser = require('./plugin/accept/acceptParser').acceptParser;
var formatXml = require('./plugin/formatter/xml').formatXml;
var authorizationParser = require('./plugin/authorization/authorization').authorizationParser;
var cors = require('./plugin/cors').cors;
var requestLogger = require('./plugin/requestLogger').requestLogger;
var etag = require('./plugin/etag').etag;

var InternalError = require('./error/internalError').InternalError;
var NotFoundError = require('./error/notFoundError').NotFoundError;
var BadRequestError = require('./error/badRequestError').BadRequestError;
var ForbiddenError = require('./error/forbiddenError').ForbiddenError;
var ServiceUnavailableError = require('./error/serviceUnavailableError').ServiceUnavailableError;
var MethodNotAllowedError = require('./error/methodNotAllowedError').MethodNotAllowedError;
var ConflictError = require('./error/conflictError').ConflictError;
var UnauthorizedError = require('./error/notAuthorizedError').UnauthorizedError;

var createServer = function createServer(routesMethods, errorHandlers, options) {

  routesMethods = routesMethods || {};
  errorHandlers = errorHandlers || {};
  options = options || {};
  options.appName = options.appName || 'API';
  options.swagger = options.swagger || {};
  options.swagger.enabled = options.swagger.enabled || false;
  options.swagger.apiDocsDir = options.swagger.apiDocsDir || false;
  options.authorization = options.authorization || {};
  options.bodyParser = options.bodyParser || {};
  options.bodyParser.enabled = options.bodyParser.enabled || false;
  options.bodyParser.options = options.bodyParser.options || {};
  options.acceptable = options.acceptable || [];

  var server = restify.createServer(
    {
      name: options.appName,
      formatters: {
        'application/xml': formatXml
      }
    }
  );

  restify.defaultResponseHeaders = false;

  server.acceptable = server.acceptable.concat(options.acceptable);

  server.on('uncaughtException', function (req, res, route, e) {
    if (res._headerSent) {
      return false;
    }

    logger.error(e);

    res.cache('no-cache', {maxAge: 0});<commit_msg>Added default json formatter for */*<commit_after>var restify = require('restify');
var logger = require('./logger/logger').logger;

var acceptParser = require('./plugin/accept/acceptParser').acceptParser;
var formatXml = require('./plugin/formatter/xml').formatXml;
var formatJSON = restify.formatters['application/json; q=0.4'];
var authorizationParser = require('./plugin/authorization/authorization').authorizationParser;
var cors = require('./plugin/cors').cors;
var requestLogger = require('./plugin/requestLogger').requestLogger;
var etag = require('./plugin/etag').etag;

var InternalError = require('./error/internalError').InternalError;
var NotFoundError = require('./error/notFoundError').NotFoundError;
var BadRequestError = require('./error/badRequestError').BadRequestError;
var ForbiddenError = require('./error/forbiddenError').ForbiddenError;
var ServiceUnavailableError = require('./error/serviceUnavailableError').ServiceUnavailableError;
var MethodNotAllowedError = require('./error/methodNotAllowedError').MethodNotAllowedError;
var ConflictError = require('./error/conflictError').ConflictError;
var UnauthorizedError = require('./error/notAuthorizedError').UnauthorizedError;

var createServer = function createServer(routesMethods, errorHandlers, options) {

  routesMethods = routesMethods || {};
  errorHandlers = errorHandlers || {};
  options = options || {};
  options.appName = options.appName || 'API';
  options.swagger = options.swagger || {};
  options.swagger.enabled = options.swagger.enabled || false;
  options.swagger.apiDocsDir = options.swagger.apiDocsDir || false;
  options.authorization = options.authorization || {};
  options.bodyParser = options.bodyParser || {};
  options.bodyParser.enabled = options.bodyParser.enabled || false;
  options.bodyParser.options = options.bodyParser.options || {};
  options.acceptable = options.acceptable || [];

  var server = restify.createServer(
    {
      name: options.appName,
      formatters: {
        'application/xml': formatXml,
        '*/*': function (req, res, body, cb) {
          formatJSON(req, res, body, function (err, data) {
            res.setHeader('content-type', 'application/json');
            return cb(err, data);
          });
        }
      }
    }
  );

  restify.defaultResponseHeaders = false;

  server.acceptable = server.acceptable.concat(options.acceptable);

  server.on('uncaughtException', function (req, res, route, e) {
    if (res._headerSent) {
      return false;
    }

    logger.error(e);

    res.cache('no-cache', {maxAge: 0});
{'fraction_non_alphanumeric': 0.14416285832987122, 'fraction_numerical': 0.0008309098462816784, 'mean_word_length': 4.732142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '1909351', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1308, 'n_words': 240}