<commit_before><?php
require_once('lib/Slim/Slim.php');
require_once('lib/rb.php');
require_once('lib/password.php');
require_once('lib/JWT.php');

require_once('jsonResponse.php');

use Slim\Slim;
Slim::registerAutoloader();

$app = new Slim();
$app->response->headers->set('Content-Type', 'application/json');

$jsonResponse = new JsonResponse();
require_once('helpers.php'); // Must come after $jsonResponse exists.

R::setup('sqlite:taskboard.db');
createInitialUser();

$app->notFound(function() use ($app, $jsonResponse) {
    $app->response->setStatus(404);
    $jsonResponse->message = 'Matching API call Not found.';

    $app->response->setBody($jsonResponse->asJson());
});

// TODO: Figure out updating token on activity.
$app->get('/authenticate', function() use($app, $jsonResponse) {
    if (validateToken()) {
        $jsonResponse->message = 'Token is authenticated.';
//         $user = getUser();
//         setUserToken($user, (0.5 * 60 * 60) /* Half an hour */);
//         R::store($user);
//         $jsonResponse->data = $user->token;
    }
    $app->response->setBody($jsonResponse->asJson());
});<commit_msg>Catch PDOException & Exceptions in cases like connection to DB failed or DB dir not writeable and return 503 status<commit_after><?php
require_once('lib/Slim/Slim.php');
require_once('lib/rb.php');
require_once('lib/password.php');
require_once('lib/JWT.php');

require_once('jsonResponse.php');

use Slim\Slim;
Slim::registerAutoloader();

$app = new Slim();
$app->response->headers->set('Content-Type', 'application/json');

$jsonResponse = new JsonResponse();
require_once('helpers.php'); // Must come after $jsonResponse exists.

// Catch Exception if connection to DB failed
try {
    R::setup('sqlite:taskboard.db');
    createInitialUser();
} catch(Exception $e) {
    $app->response->setStatus(503);
    $jsonResponse->message = 'Connection to Database failed.';

    $app->response->setBody($jsonResponse->asJson());
}

$app->notFound(function() use ($app, $jsonResponse) {
    $app->response->setStatus(404);
    $jsonResponse->message = 'Matching API call Not found.';

    $app->response->setBody($jsonResponse->asJson());
});

// TODO: Figure out updating token on activity.
$app->get('/authenticate', function() use($app, $jsonResponse) {
    if (validateToken()) {
        $jsonResponse->message = 'Token is authenticated.';
//         $user = getUser();
//         setUserToken($user, (0.5 * 60 * 60) /* Half an hour */);
//         R::store($user);
//         $jsonResponse->data = $user->token;
    }
    $app->response->setBody($jsonResponse->asJson());
});
{'fraction_non_alphanumeric': 0.19195402298850575, 'fraction_numerical': 0.009195402298850575, 'mean_word_length': 4.253521126760563, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, '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': '558016', 'n_tokens_mistral': 840, 'n_tokens_neox': 819, 'n_words': 169}