<commit_before>#!/usr/bin/env node
'use strict';

let newrelic = require('newrelic');
let crypto = require('crypto');
let express = require('express');
let fb = require('./firebase');
let logger = require('morgan');
let nunjucks = require('nunjucks');
let path = require('path');

function randomValueBase64 (len) {
    return crypto.randomBytes(Math.ceil(len * 3 / 4))
        .toString('base64')
        .slice(0, len)
        .replace(/\+/g, '0')
        .replace(/\//g, '0');
}

let app = express();

let DEBUG = app.get('env') === 'development';
let STATIC_BASE = `/static-${randomValueBase64(10)}`;

nunjucks.configure('views', {
  autoescape: true,
  express: app
});

app.use(logger('dev'));

let staticOps = {
  maxAge: DEBUG ? 0 : '360d'
};

app.use(STATIC_BASE,
  express.static(path.join(__dirname, 'public'), staticOps));

// New Relic middleware
app.locals.newrelic = newrelic;
app.use((req, res, next) => {
  res.locals.timingHeader = newrelic.getBrowserTimingHeader();
  res.locals.STATIC_BASE = STATIC_BASE;
  next();
});

app.get('/', (req, res) => {
  fb.getList().then( stories => {
    res.render('list.html', {stories: stories});
  });
});

app.get('/comments/:id', (req, res, next) => {
  fb.getComment(req.params.id).then(comment => {
    if (!comment.id) { next(); }
    res.render('comments.html', {comment: comment});
  });
});

// catch 404 and forward to error handler
app.use((req, res, next) => {
  let err = new Error('Not Found');
  err.status = 404;
  next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (DEBUG) {
  app.use((err, req, res) => {
    res.status(err.status || 500);
    res.render('error.html', {
      message: err.message,
      error: err
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use((err, req, res) => {
  res.status(err.status || 500);
  res.send(Error);
});

let server = app.listen(process.env.PORT || '3000', () => {
  let host = server.address().address;
  let port = server.address().port;
  // eslint-disable-next-line no-console 
  console.log('Listening at http://%s:%s', host, port);
});<commit_msg>Redeploy<commit_after>#!/usr/bin/env node
'use strict';

let newrelic = require('newrelic');
let crypto = require('crypto');
let express = require('express');
let fb = require('./firebase');
let logger = require('morgan');
let nunjucks = require('nunjucks');
let path = require('path');

function randomValueBase64 (len) {
    return crypto.randomBytes(Math.ceil(len * 3 / 4))
        .toString('base64')
        .slice(0, len)
        .replace(/\+/g, '0')
        .replace(/\//g, '0');
}

let app = express();

let DEBUG = app.get('env') === 'development';
let STATIC_BASE = `/static-${randomValueBase64(10)}`;

nunjucks.configure('views', {
  autoescape: true,
  express: app
});

app.use(logger('dev'));

let staticOps = {
  maxAge: DEBUG ? 0 : '360d'
};

app.use(STATIC_BASE,
  express.static(path.join(__dirname, 'public'), staticOps));

// New Relic middleware
app.locals.newrelic = newrelic;
app.use((req, res, next) => {
  res.locals.timingHeader = newrelic.getBrowserTimingHeader();
  res.locals.STATIC_BASE = STATIC_BASE;
  next();
});

app.get('/', (req, res) => {
  fb.getList().then( stories => {
    res.render('list.html', {stories: stories});
  });
});

app.get('/comments/:id', (req, res, next) => {
  fb.getComment(req.params.id).then(comment => {
    if (!comment.id) { next(); }
    res.render('comments.html', {comment: comment});
  });
});

// catch 404 and forward to error handler
app.use((req, res, next) => {
  let err = new Error('Not Found');
  err.status = 404;
  next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (DEBUG) {
  app.use((err, req, res) => {
    res.status(err.status || 500);
    res.render('error.html', {
      message: err.message,
      error: err
    });
  });
}

// production error handler
// no stacktraces leaked to user
app.use((err, req, res) => {
  res.status(err.status || 500);
  res.send(Error);
});

let server = app.listen(process.env.PORT || '3000', () => {
  let host = server.address().address;
  let port = server.address().port;
  // eslint-disable-next-line no-console 
  console.log('Listening at http://%s:%s', host, port);
});


{'fraction_non_alphanumeric': 0.20275636533520205, 'fraction_numerical': 0.015416958654519973, 'mean_word_length': 3.5796791443850267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '1096508', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1497, 'n_words': 332}