<commit_before>'use strict';

var SwaggerExpress = require('swagger-express-mw');
var express = require('express');
var app = express();


module.exports = app; // for testing

var config = {
  appRoot: __dirname // required config
};

SwaggerExpress.create(config, function(err, swaggerExpress) {
  if (err) { throw err; }

  app.use(function (req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');//req.headers.origin);
    res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
    res.header('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    next();
  });

  app.use('/docs', express.static(__dirname + '/swagger-ui'));

  app.use(function(err, req, res, next) {
    console.error(err.stack);
    res.status(500).send(err);
  });

  // install middleware
  swaggerExpress.register(app);

  var port = process.env.PORT || 80;
  app.listen(port);

  console.log('Dev API Server running on http://127.0.0.1:' + port);
});<commit_msg>got json error messages working. YAYgit add -Agit add -A Swagger has removed error handling from within itself and they need to be handled with an express middleware, as I was suspecting. You'd think they would have included one in their basic setup.<commit_after>'use strict';

var SwaggerExpress = require('swagger-express-mw');
var express = require('express');
var app = express();


module.exports = app; // for testing

var config = {
  appRoot: __dirname // required config
};

SwaggerExpress.create(config, function(err, swaggerExpress) {
  if (err) { throw err; }

  app.use(function (req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');//req.headers.origin);
    res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
    res.header('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    next();
  });

  app.use('/docs', express.static(__dirname + '/swagger-ui'));



  // install middleware
  swaggerExpress.register(app);

  app.use(function(err, req, res, next) {
    res.status(500).send(err);
  });

  var port = process.env.PORT || 80;
  app.listen(port);

  console.log('Dev API Server running on http://127.0.0.1:' + port);
});
{'fraction_non_alphanumeric': 0.1703038083012409, 'fraction_numerical': 0.009413778348309799, 'mean_word_length': 4.071583514099783, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '5123446', 'n_tokens_mistral': 774, 'n_tokens_neox': 736, 'n_words': 181}