<commit_before>/**
* ALiEM Cards API v 0.2.0
*
* JSON response based on JSend standards: http://labs.omniti.com/labs/jsend
* http://stackoverflow.com/questions/12806386/standard-json-api-response-format
*
**/
// ExpressJS Config
const express = require('express');
const router = express.Router();

// MongooseJS Config
const config = require('../../config');
const mongoose = require('mongoose');
const Card = require('../../build_db/models/card');
const Tag = require('../../build_db/models/taxonomy').tag;
const Category = require('../../build_db/models/taxonomy').category;
mongoose.Promise = require('bluebird');
mongoose.connect(config.development.mlaburi);

// RESPONSE HELPER
const apires = function apires(s, d) {
  return {
    status: s,
    data: d,
  };
};

// INDEX

router.get('/', (req, res) => {
  res.send('Here is the api');
});

// CARDS

router.get('/cards', (req, res) => {
  Card.find().select('slug title').sort({ title: 1 })
  .exec()
  .then((cards) => {
    res.json(apires('success', cards));<commit_msg>added conditional config<commit_after>/**
* ALiEM Cards API v 0.2.0
*
* JSON response based on JSend standards: http://labs.omniti.com/labs/jsend
* http://stackoverflow.com/questions/12806386/standard-json-api-response-format
*
**/
// ExpressJS Config
const express = require('express');
const router = express.Router();

// MongooseJS Config;
var config = {};
if (process.env.OPENSHIFT_NODEJS_PORT) {
  config = { development: { mlaburi: process.env.MLAB_CONNECT_STRING } };
} else {
  config = require('../../config');
}

const mongoose = require('mongoose');
const Card = require('../../build_db/models/card');
const Tag = require('../../build_db/models/taxonomy').tag;
const Category = require('../../build_db/models/taxonomy').category;
mongoose.Promise = require('bluebird');

mongoose.connect(config.development.mlaburi);

// RESPONSE HELPER
const apires = function apires(s, d) {
  return {
    status: s,
    data: d,
  };
};

// INDEX

router.get('/', (req, res) => {
  res.send('Here is the api');
});

// CARDS

router.get('/cards', (req, res) => {
  Card.find().select('slug title').sort({ title: 1 })
  .exec()
  .then((cards) => {
    res.json(apires('success', cards));
{'fraction_non_alphanumeric': 0.20072169598556608, 'fraction_numerical': 0.010825439783491205, 'mean_word_length': 3.8427947598253276, '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': '4778703', 'n_tokens_mistral': 764, 'n_tokens_neox': 751, 'n_words': 157}