<commit_before>import { interfaces } from 'inversify-express-utils';
import { Controller, Get, Post, Put, Delete, getDocs } from './inversify-express-docs';
import { injectable, inject } from 'inversify';
import { Response } from 'express';
import 'reflect-metadata';
import * as pug from 'pug';

@injectable()
@Controller('/doc')
export default class DocController implements  interfaces.Controller {
  private basePath = 'node_modules/inversify-express-doc/dist/';
  private localPath = 'src/';

  constructor(
    ) {
    }

  @Get('/')
  public getDocumentation(request: { user: any}, res: Response) {
    res.type('text/html');
    const compiledFunction = this.getCompileFunction('apidoc.pug');
    res.send(compiledFunction({ controllers: getDocs()}));
  }

  @Get('/:controller/:endpoint')
  public getEndpointDocumentation(request: any, res: Response) {
    res.type('text/html');
    const compiledFunction = this.getCompileFunction('endpointdoc.pug');
    const controllerData: { methods: any[], basePath: string } = getDocs()[request.params['controller']];
    if(this.testForExists(controllerData, res)){
      return;
    }
    const endpointData = controllerData.methods.find(endpoint => endpoint.key === request.params['endpoint']);
    if(this.testForExists(endpointData, res)) {
      return;
    }
    endpointData.basePath = controllerData.basePath;
    res.send(compiledFunction(endpointData));
  }

  private getCompileFunction(fileName: string) {
    let compiledFunction;
    try {
      compiledFunction = pug.compileFile(this.basePath + fileName);
    } catch(err) {      
      compiledFunction = pug.compileFile(this.localPath + fileName);
    }
    return compiledFunction;
  }

  private testForExists(data: any, res: any) {
    if (!data) {
      return res.status(404).send('Not Found');
    }
  }
}<commit_msg>fix(*): trigger new version<commit_after>import { interfaces } from 'inversify-express-utils';
import { Controller, Get, Post, Put, Delete, getDocs } from './inversify-express-docs';
import { injectable, inject } from 'inversify';
import { Response } from 'express';
import 'reflect-metadata';
import * as pug from 'pug';

@injectable()
@Controller('/doc')
export default class DocController implements  interfaces.Controller {
  private basePath = 'node_modules/inversify-express-doc/dist/';
  private localPath = 'src/';

  @Get('/')
  public getDocumentation(request: { user: any}, res: Response) {
    res.type('text/html');
    const compiledFunction = this.getCompileFunction('apidoc.pug');
    res.send(compiledFunction({ controllers: getDocs()}));
  }

  @Get('/:controller/:endpoint')
  public getEndpointDocumentation(request: any, res: Response) {
    res.type('text/html');
    const compiledFunction = this.getCompileFunction('endpointdoc.pug');
    const controllerData: { methods: any[], basePath: string } = getDocs()[request.params['controller']];
    if(this.testForExists(controllerData, res)){
      return;
    }
    const endpointData = controllerData.methods.find(endpoint => endpoint.key === request.params['endpoint']);
    if(this.testForExists(endpointData, res)) {
      return;
    }
    endpointData.basePath = controllerData.basePath;
    res.send(compiledFunction(endpointData));
  }

  private getCompileFunction(fileName: string) {
    let compiledFunction;
    try {
      compiledFunction = pug.compileFile(this.basePath + fileName);
    } catch(err) {      
      compiledFunction = pug.compileFile(this.localPath + fileName);
    }
    return compiledFunction;
  }

  private testForExists(data: any, res: any) {
    if (!data) {
      return res.status(404).send('Not Found');
    }
  }
}
{'fraction_non_alphanumeric': 0.14059945504087193, 'fraction_numerical': 0.0016348773841961854, 'mean_word_length': 4.1777150916784205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3268332', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1077, 'n_words': 230}