<commit_before>import { OrcheConfig } from './interfaces/orche-config';
import { OrcheResult } from './interfaces/orche-result';
import { DecoratorLoader } from './loaders/decorator.loader';
import { OrcheEngines } from './constants/orche-engines';
import { ExpressEngine } from './engines/express.engine';

export class Orche {

  init(config: OrcheConfig): Promise<OrcheResult> {
    let result: OrcheResult;

    return new Promise(async (resolve, reject) => {
      this.loadDecorators(reject);

      const engine = this.engineInitialization(config, reject);
      try {
        result = await engine.loadServer();
      } catch (error) {
        console.log('error');
        // TODO
        reject();
      }

      resolve(result);
    });
  }

  private loadDecorators(reject): Promise<any> {
    const decoratorLoader = new DecoratorLoader();

    return new Promise(async (resolve) => {
      let files: string [];
      try {
        files = await decoratorLoader.loadDecorators();
      } catch (error) {
        // TODO
        reject();
      }

      resolve(files);
    });
  }

  private engineInitialization(config: OrcheConfig, reject: any) {
    let engine;

    try {
      switch (config.apiEngine) {
        case OrcheEngines.ExpressJS:
          engine = new ExpressEngine(config);
          break;
        case OrcheEngines.Hapi:
          break;
        case OrcheEngines.Koa:
          break;
        case OrcheEngines.Restify:
          break;
        default:
          engine = new ExpressEngine(config);
          break;
      }
    } catch (error) {
      // TODO
      reject();
    }

    return engine;
  }

}<commit_msg>fix: added return post promise<commit_after>import { OrcheConfig } from './interfaces/orche-config';
import { OrcheResult } from './interfaces/orche-result';
import { DecoratorLoader } from './loaders/decorator.loader';
import { OrcheEngines } from './constants/orche-engines';
import { ExpressEngine } from './engines/express.engine';

export class Orche {

  init(config: OrcheConfig): Promise<OrcheResult> {
    let result: OrcheResult;

    return new Promise(async (resolve, reject) => {
      this.loadDecorators(reject);

      const engine = this.engineInitialization(config, reject);
      try {
        result = await engine.loadServer();
      } catch (error) {
        console.log('error');
        // TODO
        reject();
        return;
      }

      resolve(result);
    });
  }

  private loadDecorators(reject): Promise<any> {
    const decoratorLoader = new DecoratorLoader();

    return new Promise(async (resolve) => {
      let files: string [];
      try {
        files = await decoratorLoader.loadDecorators();
      } catch (error) {
        // TODO
        reject();
        return;
      }

      resolve(files);
    });
  }

  private engineInitialization(config: OrcheConfig, reject: any) {
    let engine;

    try {
      switch (config.apiEngine) {
        case OrcheEngines.ExpressJS:
          engine = new ExpressEngine(config);
          break;
        case OrcheEngines.Hapi:
          break;
        case OrcheEngines.Koa:
          break;
        case OrcheEngines.Restify:
          break;
        default:
          engine = new ExpressEngine(config);
          break;
      }
    } catch (error) {
      // TODO
      reject();
      return;
    }

    return engine;
  }

}
{'fraction_non_alphanumeric': 0.11667160201362156, 'fraction_numerical': 0.0, 'mean_word_length': 2.1867924528301885, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '2583419', 'n_tokens_mistral': 982, 'n_tokens_neox': 940, 'n_words': 223}