<commit_before>import _ from 'lodash'

export default function json(spec) {
  let type

  if (spec && spec.collection && spec.collection.modelName) {
    type = _.camelCase(spec.collection.modelName)
  }

  return function(req, res) {
    if (!res.body) {
      return res
        .status(204)
        .end()
    }

    if (type) {
      return res.json({
        [type]: res.body
      })<commit_msg>fix: get name of model<commit_after>import _ from 'lodash'
import {
  getCollectionByIdentity
} from '../db'

export default function json(spec = {}) {
  let type
  const {collection} = spec
  if (collection) {
    type = _.camelCase(collection.prototype.identity)
  }

  return function(req, res) {
    if (!res.body) {
      return res
        .status(204)
        .end()
    }

    if (type) {
      return res.json({
        [type]: res.body
      })
{'fraction_non_alphanumeric': 0.13216374269005848, 'fraction_numerical': 0.007017543859649123, 'mean_word_length': 2.292307692307692, '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': '5858887', 'n_tokens_mistral': 287, 'n_tokens_neox': 276, 'n_words': 69}