<commit_before>import * as express from 'express';
import logger from '../logger';

import { Base, Route } from '../model/route';

export function config(app: express.Express, things: Array<Base>) {
    things.forEach(t => {
        configEach(app.route(t.path), t.routes);
    });
}

function configEach(router: express.IRoute, routes: Array<Route>) {
    routes.forEach(route => {
        router[route.method](function (req: express.Request, res: express.Response) {
            try {
                const result = route.controller(req, res);
                if (result && result['then']) {
                    (<Promise<any>>result)
                        .catch((e: Error) => {
                            logger.error(`[RUNTIME_ASYNC] => ${e.stack || e}`);
                        });<commit_msg>use catch for promise check<commit_after>import * as express from 'express';
import logger from '../logger';

import { Base, Route } from '../model/route';

export function config(app: express.Express, things: Array<Base>) {
    things.forEach(t => {
        configEach(app.route(t.path), t.routes);
    });
}

function configEach(router: express.IRoute, routes: Array<Route>) {
    routes.forEach(route => {
        router[route.method](function (req: express.Request, res: express.Response) {
            try {
                const result = route.controller(req, res);
                if (result && result['catch']) {
                    (<Promise<any>>result)
                        .catch((e: Error) => {
                            logger.error(`[RUNTIME_ASYNC] => ${e.stack || e}`);
                        });
{'fraction_non_alphanumeric': 0.15422578655151142, 'fraction_numerical': 0.0, 'mean_word_length': 2.0895238095238096, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, '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': '2464558', 'n_tokens_mistral': 445, 'n_tokens_neox': 438, 'n_words': 100}