<commit_before>/*jslint node: true */
'use strict';

require('babel/register');

// Declare variables used
var app,
  base_url,
  bodyParser,
  express,
  hbs,
  morgan,
  port,
  shortid,
  React,
  Editor;

// Define values
express = require('express');
app = express();
port = process.env.PORT || 5000;
base_url = process.env.BASE_URL || 'http://localhost:5000';
bodyParser = require('body-parser');
hbs = require('hbs');
morgan = require('morgan');
React = require('react');
Editor = React.createFactory(require('./components/editor.jsx'));
shortid = require('shortid');

// Set up connection to Redis
var client;
if (process.env.REDIS_URL) {
  client = require('redis').createClient(process.env.REDIS_URL);
} else {
  client = require('redis').createClient();
}

// Set up templating
app.set('views', __dirname + '/views');
app.set('view engine', "hbs");
app.engine('hbs', require('hbs').__express);

// Register partials
hbs.registerPartials(__dirname + '/views/partials');

// Set up logging
app.use(morgan('combined'));

// Set URL
app.set('base_url', base_url);

// Handle POST data
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
      extended: true
}));

// Serve static files
app.use(express.static(__dirname + '/static'));

// Define index route
app.get('/', function (req, res) {
  var initialValue = '';
  var markup = React.renderToString(Editor({ value: initialValue }));
  res.render('index', {
    markup: markup,
    state: initialValue
  });
});

// Define submit route
app.post('/', function (req, res) {
  // Declare variables
  var text, id;

  // Get text
  text = req.body.text;

  // Create a hash
  id = shortid.generate();

  // Store them in Redis
  client.set(id, text, function () {
    // Send response
    res.json('', {id: id});
  });
});

// Define item route
app.route('/:id').all(function (req, res) {
  // Get ID
  var id = req.params.id.trim();

  // Look up the item<commit_msg>Fixed a deprecation issue<commit_after>/*jslint node: true */
'use strict';

require('babel/register');

// Declare variables used
var app,
  base_url,
  bodyParser,
  express,
  hbs,
  morgan,
  port,
  shortid,
  React,
  Editor;

// Define values
express = require('express');
app = express();
port = process.env.PORT || 5000;
base_url = process.env.BASE_URL || 'http://localhost:5000';
bodyParser = require('body-parser');
hbs = require('hbs');
morgan = require('morgan');
React = require('react');
Editor = React.createFactory(require('./components/editor.jsx'));
shortid = require('shortid');

// Set up connection to Redis
var client;
if (process.env.REDIS_URL) {
  client = require('redis').createClient(process.env.REDIS_URL);
} else {
  client = require('redis').createClient();
}

// Set up templating
app.set('views', __dirname + '/views');
app.set('view engine', "hbs");
app.engine('hbs', require('hbs').__express);

// Register partials
hbs.registerPartials(__dirname + '/views/partials');

// Set up logging
app.use(morgan('combined'));

// Set URL
app.set('base_url', base_url);

// Handle POST data
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
      extended: true
}));

// Serve static files
app.use(express.static(__dirname + '/static'));

// Define index route
app.get('/', function (req, res) {
  var initialValue = '';
  var markup = React.renderToString(Editor({ value: initialValue }));
  res.render('index', {
    markup: markup,
    state: initialValue
  });
});

// Define submit route
app.post('/', function (req, res) {
  // Declare variables
  var text, id;

  // Get text
  text = req.body.text;

  // Create a hash
  id = shortid.generate();

  // Store them in Redis
  client.set(id, text, function () {
    // Send response
    res.status(201).json({id: id});
  });
});

// Define item route
app.route('/:id').all(function (req, res) {
  // Get ID
  var id = req.params.id.trim();

  // Look up the item
{'fraction_non_alphanumeric': 0.18177136972193614, 'fraction_numerical': 0.004891864057672502, 'mean_word_length': 3.7844827586206895, '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': '3881358', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1291, 'n_words': 321}