<commit_before>'use strict';

const Router = require('./index');
const inherits = require('util').inherits;

function HealthRouter(options) {
  if(!(this instanceof HealthRouter)) {
    return new HealthRouter(options);
  }

  Router.apply(this, arguments);
}

inherits(HealthRouter, Router);

HealthRouter.prototype.health = function(req, res) {
  if (!this.storage) {
    res.status(503).send('Service Unavailable');
  }

  res.status(200).send('OK');
};

HealthRouter.prototype._definitions = function() {
  return [
    ['GET', '/health', this.health]
  ];
};

module.exports = HealthRouter;
<commit_msg>Change connection check for healthcheck endpoint<commit_after>'use strict';

const Router = require('./index');
const inherits = require('util').inherits;

function HealthRouter(options) {
  if(!(this instanceof HealthRouter)) {
    return new HealthRouter(options);
  }

  Router.apply(this, arguments);
}

inherits(HealthRouter, Router);

HealthRouter.prototype.health = function(req, res) {
  if (!this.storage.connection.readyState === 1) {
    res.status(503).send('Service Unavailable');
  }

  res.status(200).send('OK');
};

HealthRouter.prototype._definitions = function() {
  return [
    ['GET', '/health', this.health]
  ];
};

module.exports = HealthRouter;

{'fraction_non_alphanumeric': 0.16184519155590305, 'fraction_numerical': 0.010164190774042221, 'mean_word_length': 4.818181818181818, 'pattern_counts': {'":': 0, '<': 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': '2945222', 'n_tokens_mistral': 405, 'n_tokens_neox': 389, 'n_words': 78}