<commit_before>'use strict';

const express = require('express');
const moment = require('moment');

const app = express();
const port = process.argv[2] || 3000;

app.get('/:timestamp', (request, response) => {
  const timestamp = request.params.timestamp;

  let result = {};

  if (moment.unix(timestamp).isValid()) {
    result = {
      unix: parseInt(timestamp),
      natural: moment.unix(timestamp).format('MMMM D, YYYY')
    }
  } else if (moment(new Date(timestamp)).isValid()) {
    result = {
      unix: moment(new Date(timestamp)).format('X'),
      natural: moment(new Date(timestamp)).format('MMMM D, YYYY')
    }
  } else {
    result = {
      unix: null,
      natural: null
    }
  }

  response.end(JSON.stringify(result));
});

app.listen(port, () => {
  console.log(`Server listening on port ${port}...`);
})<commit_msg>Use express' response.json() method because it sets proper header automatically<commit_after>'use strict';

const express = require('express');
const moment = require('moment');

const app = express();
const port = process.argv[2] || 3000;

app.get('/:timestamp', (request, response) => {
  const timestamp = request.params.timestamp;

  let result = {};

  if (moment.unix(timestamp).isValid()) {
    result = {
      unix: parseInt(timestamp),
      natural: moment.unix(timestamp).format('MMMM D, YYYY')
    }
  } else if (moment(new Date(timestamp)).isValid()) {
    result = {
      unix: moment(new Date(timestamp)).format('X'),
      natural: moment(new Date(timestamp)).format('MMMM D, YYYY')
    }
  } else {
    result = {
      unix: null,
      natural: null
    }
  }

  response.json(result);
});

app.listen(port, () => {
  console.log(`Server listening on port ${port}...`);
})
{'fraction_non_alphanumeric': 0.17694524495677233, 'fraction_numerical': 0.005763688760806916, 'mean_word_length': 3.4742268041237114, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1927817', 'n_tokens_mistral': 548, 'n_tokens_neox': 545, 'n_words': 125}