<commit_before>#!/usr/bin/env node

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

var request = require('request');
var dbModels = require('../lib/db-models');

module.exports = function (mongoose, dbconn, makeAPIPublisher) {
  var Component = dbModels.get('Component');
  var App = dbModels.get('App');

  var checkAuthorised = function(request, response, next) {
    if (! request.session.email) {
      response.json(401, {error: 'need to be signed in'});
      return false;
    }
    if(next) next();
    return true;
  };

  return {
    apps: function(request, response) {
      if (!checkAuthorised(request, response)) return;

      App.find({author:request.session.email}).sort({"name":1}).exec(function (err, apps) {
        if (err){
          console.log('Unable to retrieve apps');
          return response.json(500, 'Unable to retrieve apps: ' + err);<commit_msg>Ripped out server-side sort of app list<commit_after>#!/usr/bin/env node

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

var request = require('request');
var dbModels = require('../lib/db-models');

module.exports = function (mongoose, dbconn, makeAPIPublisher) {
  var Component = dbModels.get('Component');
  var App = dbModels.get('App');

  var checkAuthorised = function(request, response, next) {
    if (! request.session.email) {
      response.json(401, {error: 'need to be signed in'});
      return false;
    }
    if(next) next();
    return true;
  };

  return {
    apps: function(request, response) {
      if (!checkAuthorised(request, response)) return;

      App.find({author:request.session.email}).exec(function (err, apps) {
        if (err){
          console.log('Unable to retrieve apps');
          return response.json(500, 'Unable to retrieve apps: ' + err);
{'fraction_non_alphanumeric': 0.1413512218495448, 'fraction_numerical': 0.010062290368950648, 'mean_word_length': 3.2699386503067487, 'pattern_counts': {'":': 1, '<': 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': '6457748', 'n_tokens_mistral': 645, 'n_tokens_neox': 622, 'n_words': 199}