<commit_before>/* eslint no-console: "off" */

require('dotenv').load();

const path = require('path');

const Koa = require('koa');

const Router = require('koa-router');

const views = require('koa-views');

const serve = require('koa-static');

const app = new Koa();
const router = new Router();

/* Set global state */
app.use(async (ctx, next) => {
  ctx.state.assetServer = process.env.NODE_ENV === 'production' ? '' : '//localhost:9191';
  await next();
});

app.use(serve(path.resolve(__dirname, '../public')));
app.use(serve(path.resolve(__dirname, '../resources')));

/* Template rendering using dustjs */
app.use(views(path.resolve(__dirname, 'views'), {
  map: {
    html: 'dust',
  },
}));

/* Routes */
router.get('/', async (ctx, next) => {
  await ctx.render('index');
  await next();
});

app.use(router.routes());
app.use(router.allowedMethods());

app.listen(process.env.PORT, () => {
  console.log(`Server running at port ${process.env.PORT}`);
});
<commit_msg>cache template if in production server<commit_after>/* eslint no-console: "off" */

require('dotenv').load();

const path = require('path');

const Koa = require('koa');

const Router = require('koa-router');

const views = require('koa-views');

const serve = require('koa-static');

const app = new Koa();
const router = new Router();

/* Set global state */
app.use(async (ctx, next) => {
  ctx.state.assetServer = process.env.NODE_ENV === 'production' ? '' : '//localhost:9191';
  await next();
});

app.use(serve(path.resolve(__dirname, '../public')));
app.use(serve(path.resolve(__dirname, '../resources')));

/* Template rendering using dustjs */
app.use(views(path.resolve(__dirname, 'views'), {
  cache: process.env.NODE_ENV === 'production',
  map: {
    html: 'dust',
  },
}));

/* Routes */
router.get('/', async (ctx, next) => {
  await ctx.render('index');
  await next();
});

app.use(router.routes());
app.use(router.allowedMethods());

app.listen(process.env.PORT, () => {
  console.log(`Server running at port ${process.env.PORT}`);
});

{'fraction_non_alphanumeric': 0.22140402552773686, 'fraction_numerical': 0.0039273441335297005, 'mean_word_length': 4.478494623655914, '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': '6765439', 'n_tokens_mistral': 687, 'n_tokens_neox': 690, 'n_words': 148}