<commit_before>const express = require("express"),
  router = express.Router(),
  { listObjects, getObject, isDir } = require("./../services/s3");

const errObject = (err, path) => ({
  message: `${err.message}: ${path}`,
  reason: err.code
});

router.get("/*", (req, res) => {
  const path = req.params["0"];
  const cb = (err, data) => {
    if (err) res.status(err.statusCode).json(errObject(err, path));
    else res.json(data);
  };
  if (isDir(path)) listObjects(path, cb);
  else getObject(path, cb);
});

module.exports = router;<commit_msg>import isDir from util<commit_after>const express = require("express"),
  router = express.Router(),
  { isDir } = require("./util"),
  { listObjects, getObject } = require("./../services/s3");

const errObject = (err, path) => ({
  message: `${err.message}: ${path}`,
  reason: err.code
});

router.get("/*", (req, res) => {
  const path = req.params["0"];
  const cb = (err, data) => {
    if (err) res.status(err.statusCode).json(errObject(err, path));
    else res.json(data);
  };
  if (isDir(path)) listObjects(path, cb);
  else getObject(path, cb);
});

module.exports = router;
{'fraction_non_alphanumeric': 0.21762114537444935, 'fraction_numerical': 0.003524229074889868, 'mean_word_length': 4.071428571428571, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1880197', 'n_tokens_mistral': 394, 'n_tokens_neox': 394, 'n_words': 89}