<commit_before>const fs = require('fs');
const tls = require('tls');
const dotenv = require('dotenv');
const fastify = require('fastify');
const moment = require('moment');
const chalk = require('chalk');

// Show splash.
const splash = require('./package.json');
console.log(chalk`\n{underline.magentaBright ${splash.description} v${splash.version}} {gray (${splash.license})}\n`);

// Load environment variables from file.
dotenv.config();

// Allow requests to sites with TLSv1 certificates.
tls.DEFAULT_MIN_VERSION = 'TLSv1';

const db = require('./db.js');
const data = require('./data.js');
const cache = require('./utils/cache.js');
const log = require('./utils/log.js');

// Initialize HTTP server.
const app = fastify();

// Register custom not found handler.
app.setNotFoundHandler((req, res) => {
	res.status(404).send();
});

// Register custom error handler.
app.setErrorHandler((err, req, res) => {
	if (err.message !== 'Not Found') log.warn`Error in route ${decodeURIComponent(req.raw.url)}.${err}`;
	res.send(err.stack);
});

// Dynamically register routes from folder.
for (const file of fs.readdirSync('routes')) app.register(require(`./routes/${file}`));

// Initialize database if needed, update data and start listening on port.
(async function() {
	try {
		await db.query(fs.readFileSync('data/init.sql').toString());<commit_msg>Improve error message<commit_after>const fs = require('fs');
const tls = require('tls');
const dotenv = require('dotenv');
const fastify = require('fastify');
const moment = require('moment');
const chalk = require('chalk');

// Show splash.
const splash = require('./package.json');
console.log(chalk`\n{underline.magentaBright ${splash.description} v${splash.version}} {gray (${splash.license})}\n`);

// Load environment variables from file.
dotenv.config();

// Allow requests to sites with TLSv1 certificates.
tls.DEFAULT_MIN_VERSION = 'TLSv1';

const db = require('./db.js');
const data = require('./data.js');
const cache = require('./utils/cache.js');
const log = require('./utils/log.js');

// Initialize HTTP server.
const app = fastify();

// Register custom not found handler.
app.setNotFoundHandler((req, res) => {
	res.status(404).send();
});

// Register custom error handler.
app.setErrorHandler((err, req, res) => {
	if (err.message !== 'Not Found') log.warn`Error in route ${decodeURIComponent(req.raw.url)}.${err}`;
	res.send(err.message);
});

// Dynamically register routes from folder.
for (const file of fs.readdirSync('routes')) app.register(require(`./routes/${file}`));

// Initialize database if needed, update data and start listening on port.
(async function() {
	try {
		await db.query(fs.readFileSync('data/init.sql').toString());
{'fraction_non_alphanumeric': 0.1836283185840708, 'fraction_numerical': 0.003687315634218289, 'mean_word_length': 4.936542669584245, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1712434', 'n_tokens_mistral': 837, 'n_tokens_neox': 835, 'n_words': 225}