<commit_before>import { BodyParserConfig, edk, HTTP_INTERCEPTORS } from '@ditsmod/core';
import { Injectable, InjectionToken, ReflectiveInjector } from '@ts-stack/di';

import { BodyParserInterceptor } from './body-parser.interceptor';

export const BODY_PARSER_EXTENSIONS = new InjectionToken<edk.Extension<void>[]>('BODY_PARSER_EXTENSIONS');

@Injectable()
export class BodyParserExtension implements edk.Extension<void> {
  private inited: boolean;

  constructor(protected extensionManager: edk.ExtensionsManager, protected injectorPerApp: ReflectiveInjector) {}

  async init() {
    if (this.inited) {
      return;
    }

    const metadataPerMod2Arr = await this.extensionManager.init(edk.ROUTES_EXTENSIONS);
    metadataPerMod2Arr.forEach((metadataPerMod2) => {
      const { metaForExtensionsPerRouArr, providersPerMod } = metadataPerMod2;
      metaForExtensionsPerRouArr.forEach(({ providersPerRou, providersPerReq }) => {
        const injectorPerMod = this.injectorPerApp.resolveAndCreateChild(providersPerMod);
        const injectorPerRou = injectorPerMod.resolveAndCreateChild(providersPerRou);
        const injectorPerReq = injectorPerRou.resolveAndCreateChild(providersPerReq);
        const routeMeta = injectorPerRou.get(edk.RouteMeta) as edk.RouteMeta;
        const bodyParserConfig = injectorPerReq.resolveAndInstantiate(BodyParserConfig) as BodyParserConfig;
        if (bodyParserConfig.acceptMethods.includes(routeMeta.httpMethod)) {
          providersPerReq.push({ provide: HTTP_INTERCEPTORS, useClass: BodyParserInterceptor, multi: true });
        }
      });
    });

    this.inited = true;
  }
}<commit_msg>fix(body-parser): fixed ExtensionsManagerPerMod<commit_after>import { BodyParserConfig, edk, HTTP_INTERCEPTORS } from '@ditsmod/core';
import { Injectable, InjectionToken, ReflectiveInjector } from '@ts-stack/di';

import { BodyParserInterceptor } from './body-parser.interceptor';

export const BODY_PARSER_EXTENSIONS = new InjectionToken<edk.Extension<void>[]>('BODY_PARSER_EXTENSIONS');

@Injectable()
export class BodyParserExtension implements edk.Extension<void> {
  private inited: boolean;

  constructor(protected extensionManager: edk.ExtensionsManagerPerMod, protected injectorPerApp: ReflectiveInjector) {}

  async init() {
    if (this.inited) {
      return;
    }

    const metadataPerMod2Arr = await this.extensionManager.init(edk.ROUTES_EXTENSIONS);
    metadataPerMod2Arr.forEach((metadataPerMod2) => {
      const { metaForExtensionsPerRouArr, providersPerMod } = metadataPerMod2;
      metaForExtensionsPerRouArr.forEach(({ providersPerRou, providersPerReq }) => {
        const injectorPerMod = this.injectorPerApp.resolveAndCreateChild(providersPerMod);
        const injectorPerRou = injectorPerMod.resolveAndCreateChild(providersPerRou);
        const injectorPerReq = injectorPerRou.resolveAndCreateChild(providersPerReq);
        const routeMeta = injectorPerRou.get(edk.RouteMeta) as edk.RouteMeta;
        const bodyParserConfig = injectorPerReq.resolveAndInstantiate(BodyParserConfig) as BodyParserConfig;
        if (bodyParserConfig.acceptMethods.includes(routeMeta.httpMethod)) {
          providersPerReq.push({ provide: HTTP_INTERCEPTORS, useClass: BodyParserInterceptor, multi: true });
        }
      });
    });

    this.inited = true;
  }
}
{'fraction_non_alphanumeric': 0.09626955475330927, 'fraction_numerical': 0.0024067388688327317, 'mean_word_length': 5.023550724637682, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '4326174', 'n_tokens_mistral': 996, 'n_tokens_neox': 988, 'n_words': 168}