<commit_before>
var jwt = require('jsonwebtoken');
var mime = require('mime');
var local = require('../../config/local');
var errors = require('../errors');
var clustering = require('../services/clustering');
var attachments = require('../services/attachments');

exports.getOne = function (db, data, response) {
  // Parameters
  //   db
  //     Monk db instance
  //   data
  //     token
  //       JWT token string
  //     locationId
  //       object id as string
  //   response
  //     Socket.io response

  if (typeof data.token !== 'string') {
    return response(errors.responses.InvalidRequestError);
  }

  if (typeof data.locationId !== 'string') {
    return response(errors.responses.InvalidRequestError);
  }

  jwt.verify(data.token, local.secret, function (err) {
    if (err) {
      return response(errors.responses.InvalidTokenError);
    }

    var locations = db.get('locations');

    locations.findOne({ _id: data.locationId }).then(function (loc) {
      if (loc) {

        // Transform location to be suitable for the client.
        loc.content = loc.content.map(function (entry) {
          if (entry.type === 'attachment') {
            // Attach an url to each attachment.
            entry.data.url = attachments.getAbsoluteUrl(entry);

            // Figure out the content mime type.
            entry.data.mimetype = mime.lookup(entry.data.filename);
          }
          return entry;
        });

        return response({
          success: loc,
        });<commit_msg>api: lookup mime type only if not already available<commit_after>
var jwt = require('jsonwebtoken');
var mime = require('mime');
var local = require('../../config/local');
var errors = require('../errors');
var clustering = require('../services/clustering');
var attachments = require('../services/attachments');

exports.getOne = function (db, data, response) {
  // Parameters
  //   db
  //     Monk db instance
  //   data
  //     token
  //       JWT token string
  //     locationId
  //       object id as string
  //   response
  //     Socket.io response

  if (typeof data.token !== 'string') {
    return response(errors.responses.InvalidRequestError);
  }

  if (typeof data.locationId !== 'string') {
    return response(errors.responses.InvalidRequestError);
  }

  jwt.verify(data.token, local.secret, function (err) {
    if (err) {
      return response(errors.responses.InvalidTokenError);
    }

    var locations = db.get('locations');

    locations.findOne({ _id: data.locationId }).then(function (loc) {
      if (loc) {

        // Transform location to be suitable for the client.
        loc.content = loc.content.map(function (entry) {
          if (entry.type === 'attachment') {
            // Attach an url to each attachment.
            entry.data.url = attachments.getAbsoluteUrl(entry);

            // Figure out the content mime type.
            if (!entry.data.hasOwnProperty('mimetype')) {
              entry.data.mimetype = mime.lookup(entry.data.filename);
            }
          }
          return entry;
        });

        return response({
          success: loc,
        });
{'fraction_non_alphanumeric': 0.1371173469387755, 'fraction_numerical': 0.0, 'mean_word_length': 2.250777202072539, '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': '3684257', 'n_tokens_mistral': 906, 'n_tokens_neox': 872, 'n_words': 226}