<commit_before>var auth_header = 'fakeauth';

// data
var apps = require('./data/apps');
var stages = require('./data/stages');
var users = require('./data/users');

// modules
var utils = require('./utils');

var uuids = [];

module.exports = function (app) {
  app.all('/bad/*', function (req, res, next) {
    return res.send(500, {"message": "a non-offensive message"});
  });

  app.post('/login', function (req, res) {
    if (!utils.contains(users, req.body.username)) {
      return res.send(401);
    }

    var id = utils.id();
    uuids.push(id);
    res.cookie('fakeauth', id);
    res.send(200, id);
  });

  // authenticate all other requests
  app.all('*', function (req, res, next) {
    if (!utils.contains(uuids, req.cookies[auth_header])) {
      return res.send(401);
    }
<commit_msg>add error message to bad logins in the api mock<commit_after>var auth_header = 'fakeauth';

// data
var apps = require('./data/apps');
var stages = require('./data/stages');
var users = require('./data/users');

// modules
var utils = require('./utils');

var uuids = [];

module.exports = function (app) {
  app.all('/bad/*', function (req, res, next) {
    return res.send(500, {"message": "a non-offensive message"});
  });

  app.post('/login', function (req, res) {
    if (!utils.contains(users, req.body.username)) {
      return res.send(401, {"message": "bad username message from backend"});
    }

    var id = utils.id();
    uuids.push(id);
    res.cookie('fakeauth', id);
    res.send(200, id);
  });

  // authenticate all other requests
  app.all('*', function (req, res, next) {
    if (!utils.contains(uuids, req.cookies[auth_header])) {
      return res.send(401);
    }

{'fraction_non_alphanumeric': 0.1957547169811321, 'fraction_numerical': 0.014150943396226415, 'mean_word_length': 3.2853535353535355, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '711821', 'n_tokens_mistral': 588, 'n_tokens_neox': 562, 'n_words': 143}