<commit_before>export default class {

  constructor(auth) {
    this.auth = auth;
  }

  /*
  * npm whoami sends its token to the server and requests a username
  * This route verifies which user is logged in and sends back its username
  */
  process(httpRequest, httpResponse) {
    let token = httpRequest.headers.authorization.substr(7);
    let user;

    return new Promise((resolve, reject) => {
      user = this.auth.verifyToken(token);

      if (user !== false) {
        httpResponse.send({
          username: user
        });
        resolve();
      } else {
        reject();
      }
    }).catch(() => {
      httpResponse.status(401);
      httpResponse.send('401, invalid user');
    });
  }
}<commit_msg>Make auth-whoami route asynchronous<commit_after>export default class {

  constructor(auth) {
    this.auth = auth;
  }

  /*
  * npm whoami sends its token to the server and requests a username
  * This route verifies which user is logged in and sends back its username
  */
  process(httpRequest, httpResponse) {
    return new Promise((resolve, reject) => {
      let token = httpRequest.headers.authorization.substr(7);
      let user;
      user = this.auth.verifyToken(token);

      if (user !== false) {
        httpResponse.send({
          username: user
        });
        resolve();
      } else {
        reject();
      }
    }).catch(() => {
      httpResponse.status(401);
      httpResponse.send('401, invalid user');
    });
  }
}
{'fraction_non_alphanumeric': 0.12135593220338983, 'fraction_numerical': 0.009491525423728813, 'mean_word_length': 2.3698630136986303, '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': '3363888', 'n_tokens_mistral': 432, 'n_tokens_neox': 411, 'n_words': 119}