{"id":329467,"date":"2022-02-12T15:00:11","date_gmt":"2022-02-12T15:00:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=329467"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=329467","title":{"rendered":"<span>\u041f\u0438\u0448\u0435\u043c nest.js \u0441 \u043d\u0443\u043b\u044f \u043d\u0430 typescript<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0426\u0438\u0442\u0430\u0442\u0430 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:  <\/p>\n<blockquote>\n<p>Nest \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u0435, \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0435, \u0441\u043b\u0430\u0431\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0438 \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0432 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u0435\u043d\u0430 Angular.  <\/p>\n<\/blockquote>\n<p>Nest \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f &#8212; dependency injection. \u041c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043a\u0430\u043a \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 Nest \u0438 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f nestjs \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<p><strong>main.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { NestFactory } from \"@nestjs\/core\"; import { AppModule } from \".\/app.module\";   async function bootstrap() {     const app = await NestFactory.create(AppModule);     await app.listen(3000); }   bootstrap();<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a. <em>NestFactory<\/em> \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 nest \u0441 \u0447\u0435\u0433\u043e \u0432\u0441\u0435 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f. \u0415\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <em>create <\/em>\u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f AppModule, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u041f\u043e\u0441\u043b\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 listen \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435, \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c\u0438 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435.\u00a0<\/p>\n<p>\u041a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u044b \u043f\u0440\u0438\u0434\u0435\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435, \u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u0438\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0438 \u043c\u043e\u0434\u0443\u043b\u044c.<\/p>\n<p><strong>app.controller.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Controller, Get, Post, Body, Param } from 'nestjs\/common'; import { AppService } from '.\/app.service';   @Controller() export class AppController {   constructor(private readonly appService: AppService) {}     @Get()   getHello(): string {     return this.appService.getHello();   }     @Post('body\/:id')   recieveBody(@Body() data: { recieveData: string }, @Param('id') id: string) {     return 'body: ' + data.recieveData + ' has been recieved and id: ' + 'id';   } } <\/code><\/pre>\n<p>\u0427\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043c\u0435\u0442\u043e\u0434\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0432\u0435\u0448\u0438\u0432\u0430\u0435\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f callbacks \u0434\u043b\u044f \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432. \u041c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0432\u0441\u0435, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c, \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435. \u041c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0430 \u043d\u0435 \u043a\u0430\u043a, \u0442\u043e \u0435\u0441\u0442\u044c, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 Nest, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c AppService, \u043a\u043e\u0442\u043e\u0440\u0443\u044e Nest \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u0442 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0414\u043b\u044f \u043d\u0430\u0441 \u0436\u0435, \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 Nest \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0442\u0438\u043f\u0443, \u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e.<\/p>\n<p><strong>app.service.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Injectable } from 'nestjs\/common';   @Injectable() export class AppService {   getHello(): string {     return 'Hello World!';   } } <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 Injectable, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 AppService \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 Nest, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u0430\u0432\u0434\u043e\u0439. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u0435, \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442, \u044d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 \u043a\u043b\u0430\u0441\u0441\u0430. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0438\u0437\u043d\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438 \u0441\u0430\u043c Nest \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c, \u0442\u043e Injectable \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c. \u0410 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 Nest \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 providers \u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.  <\/p>\n<p><strong>app.module.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Module } from 'nestjs\/common'; import { AppController } from '.\/app.controller'; import { AppService } from '.\/app.service';   @Module({   imports: [],   controllers: [AppController],   providers: [AppService], }) export class AppModule {}<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a <strong>main.ts<\/strong>, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c <strong>NestFactory<\/strong> \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u0440\u043e\u0434\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 null \u0438 \u0442.\u0434., \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0443\u0449\u0435\u043d\u044b \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435.<\/p>\n<p><strong>.\/core\/nest-factory.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { NestApplication } from \".\/nest-application\"; import { NestContainer } from \".\/injector\/container\"; import { InstanceLoader } from \".\/injector\/instance-loader\"; import { DependenciesScanner } from \".\/scanner\"; import { ExpressAdapter } from '..\/platform-express\/express.adapter';   export class NestFactoryStatic {     public async create(module: any) {         const container = new NestContainer();   \/\/ \u0421\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b   \/\/ \u0438 \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u0442 \u0438\u0445         await this.initialize(module, container);     \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 http \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0440\u043e\u0443\u0442\u0435\u0440\u044b    \/\/ \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 instance.listen(3000)         const httpServer = new ExpressAdapter()         container.setHttpAdapter(httpServer);         const instance = new NestApplication(             container,             httpServer,             applicationConfig,         );                 return instance;     }       private async initialize(         module: any,         container: NestContainer,     ) {         const instanceLoader = new InstanceLoader(container)         const dependenciesScanner = new DependenciesScanner(container);           await dependenciesScanner.scan(module);         await instanceLoader.createInstancesOfDependencies();     } }     \/**  * \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 NestFactory \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.  *  * ### \u0423\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f  *  * \u041f\u0435\u0440\u0435\u0434\u0430\u0439\u0442\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0439 *root module* (\u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c) \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f  * \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043c\u043e\u0434\u0443\u043b\u044f. \u041f\u043e \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044e \u043e\u043d \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f  * `AppModule`. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f Nest \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0433\u0440\u0430\u0444  * \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430  * \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.  *  * @publicApi  *\/ export const NestFactory = new NestFactoryStatic(); <\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a. \u0418\u0437 \u043a\u043e\u0434\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0441\u043f\u0435\u0440\u0432\u0430 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f http \u0441\u0435\u0440\u0432\u0435\u0440. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 DependenciesScanner. \u041e\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439, \u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0443\u0433\u0430\u0442\u044c\u0441\u044f, \u0432\u0435\u0434\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0442\u0430\u043c \u043d\u0435\u0442.  <\/p>\n<p><strong>.\/core\/scanner.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { MODULE_METADATA } from \"..\/common\/constants\"; import { NestContainer } from \".\/injector\/container\"; import 'reflect-metadata'; import { Module } from \".\/injector\/module\";   export class DependenciesScanner {       constructor(private readonly container: NestContainer) {}       public async scan(module: any) {         \/\/ \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440         await this.scanForModules(module);         \/\/ \u041f\u043e\u0441\u043b\u0435 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a Controllers \u0438 Providers         await this.scanModulesForDependencies();     }       public async scanForModules(module: any) {         \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440         const moduleInstance = await this.insertModule(module);         \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 imports.         \/\/ \u0422\u0430\u043a \u043a\u0430\u043a AppModule - \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0442\u043e \u043e\u0442 \u043d\u0435\u0433\u043e \u0438\u0434\u0435\u0442 \u0434\u0435\u0440\u0435\u0432\u043e \u043c\u043e\u0434\u0443\u043b\u0435\u0439.         const innerModules = [...this.reflectMetadata(moduleInstance, MODULE_METADATA.IMPORTS)];           \/\/ \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043d\u0438\u043c\u0438 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435.         \/\/ \u0422\u043e \u0435\u0441\u0442\u044c, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f.         for (const [index, innerModule] of innerModules.entries()) {             await this.scanForModules(innerModule)         }           return moduleInstance     }       \/**      * \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440      *\/     public async insertModule(module: any) {         return this.container.addModule(module);     }         \/**      * \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432\u0441\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0443 \u043d\u0438\u0445      * \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 reflect \u043e\u0431\u044a\u0435\u043a\u0442\u0435.      *\/     public async scanModulesForDependencies() {         const modules: Map&lt;string, Module> = this.container.getModules();           for (const [token, { metatype }] of modules) {             await this.reflectAndAddImports(metatype, token);             this.reflectAndAddProviders(metatype, token);             this.reflectAndAddControllers(metatype, token);         }     }       public async reflectAndAddImports(         module: any,         token: string,     ) {         \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e imports \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440         const modules = this.reflectMetadata(module, MODULE_METADATA.IMPORTS);         for (const related of modules) {             await this.container.addImport(related, token);         }     }       public reflectAndAddProviders(         module: any,         token: string,     ) {         \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e providers \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440         const providers = this.reflectMetadata(module, MODULE_METADATA.PROVIDERS);         providers.forEach((provider: any) =>             this.container.addProvider(provider, token),         );     }       public reflectAndAddControllers(module: any, token: string) {         \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e controllers \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440         const controllers = this.reflectMetadata(module, MODULE_METADATA.CONTROLLERS);         controllers.forEach((controller: any) =>             this.container.addController(controller, token),         );     }       \/**      * \u041c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u0438 \u043a\u043b\u044e\u0447\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.      *\/     public reflectMetadata(metatype: any, metadataKey: string) {         return Reflect.getMetadata(metadataKey, metatype) || [];     } } <\/code><\/pre>\n<p>\u0421\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043a\u043e\u0434, \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u0438 \u0438 \u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0438 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0434\u0432\u0443\u043c \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u0437\u0434\u0435\u0441\u044c &#8212; NestContainer \u0438 Module. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0438 \u043a\u0430\u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u0430 Module, \u0438 \u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b, \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 Module, \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043a Map \u0438 Set. \u0410 \u0441\u0430\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 InstanceWrapper.\u00a0<\/p>\n<p>\u041a\u043b\u0430\u0441\u0441\u044b Module \u0438 InstanceWrapper \u0432 \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0442\u043e\u0440\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440.<\/p>\n<p><strong>.\/core\/injector\/container.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Module } from \".\/module\"; import { ModuleTokenFactory } from \".\/module-token-factory\"; import { AbstractHttpAdapter } from \"..\/adapters\";   export class NestContainer {     private readonly modules = new Map&lt;string, Module>();     private readonly moduleTokenFactory = new ModuleTokenFactory();     private httpAdapter: AbstractHttpAdapter | undefined;       \/**      * \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 Module \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440      *\/     public async addModule(module: any) {         \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u0442\u043e\u043a\u0435\u043d \u043c\u043e\u0434\u0443\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0435\u0433\u043e \u043a\u043b\u044e\u0447\u043e\u043c Map,         \/\/ \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f.         const token = this.moduleTokenFactory.create(module);           if (this.modules.has(module.name)) {             return;         }           const moduleRef = new Module(module);         moduleRef.token = token;         this.modules.set(token, moduleRef);           return moduleRef;     }       \/**      * \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u0434\u043b\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439,      * \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u044d\u0442\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0438 \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 callbacks      * \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432 \u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0441 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438.      *\/     public getModules(): Map&lt;string, Module> {         return this.modules;     }       \/**      * \u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0442\u0430\u043a\u0436\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438 \u0445\u0440\u0430\u043d\u0438\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 http \u0441\u0435\u0440\u0432\u0435\u0440\u0430,      * \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 express. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 NestFactory.      *\/     public setHttpAdapter(httpAdapter: any) {         this.httpAdapter = httpAdapter;     }       \/**      * \u0411\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 RouterExplorer.      *\/     public getHttpAdapterRef() {         return this.httpAdapter;     }           \/**      * \u041f\u0440\u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 DependenciesScanner,      * \u0443 \u043d\u0438\u0445 \u0442\u0430\u043a\u0436\u0435 \u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0442\u043e\u043a\u0435\u043d, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c,      * \u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u043e\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a \u0441\u0435\u0431\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c.      *\/     public async addImport(         relatedModule: any,         token: string,     ) {         if (!this.modules.has(token)) {             return;         }         const moduleRef = this.modules.get(token);         if (!moduleRef) {             throw Error('MODULE NOT EXIST')         }           const related = this.modules.get(relatedModule.name);         if (!related) {             throw Error('RELATED MODULE NOT EXIST')         }         moduleRef.addRelatedModule(related);     }       \/**      * \u0422\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u0438 \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c      * \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432.      *\/     public addProvider(provider: any, token: string) {         if (!this.modules.has(token)) {             throw new Error('Module not found.');         }         const moduleRef = this.modules.get(token);         if (!moduleRef) {             throw Error('MODULE NOT EXIST')         }         moduleRef.addProvider(provider)     }       \/**      * \u0422\u0430\u043a\u0436\u0435 \u043a\u0430\u043a \u0438 \u0434\u043b\u044f \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c      * \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432.      *\/     public addController(controller: any, token: string) {         if (!this.modules.has(token)) {             throw new Error('Module not found.');         }         const moduleRef = this.modules.get(token);         if (!moduleRef) {             throw Error('MODULE NOT EXIST')         }         moduleRef.addController(controller);     } } <\/code><\/pre>\n<p>\u041c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u0437\u0434\u0435\u0441\u044c \u0442\u0430\u043a\u0436\u0435 \u043a\u043b\u0430\u0441\u0441 ModuleTokenFactory, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0442\u043e\u043a\u0435\u043d, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0437\u0434\u0435\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e id, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0430\u043a\u0435\u0442\u0430 uuid. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u0430 \u044d\u0442\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u043d\u043e, \u043a\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0432\u043e\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Nest, \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u0430\u044f.  <\/p>\n<p><strong>.\/core\/injector\/module-token-factory.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import hash from 'object-hash'; import { v4 as uuid } from 'uuid'; import { Type } from '..\/..\/common\/interfaces\/type.interface';   export class ModuleTokenFactory {     \/\/ \u0417\u0434\u0435\u0441\u044c \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u043e\u0442\u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u044b.     \/\/ \u041d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439 \u0442\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u043e\u0434\u0438\u043d \u043c\u043e\u0434\u0443\u043b\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445,     \/\/ \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u0434\u0443\u0431\u043b\u0438\u043a\u0430\u0442\u043e\u0432.     private readonly moduleIdsCashe = new WeakMap&lt;Type&lt;unknown>, string>()       public create(metatype: Type&lt;unknown>): string {         const moduleId = this.getModuleId(metatype);         const opaqueToken = {             id: moduleId,             module: this.getModuleName(metatype),         };         return hash(opaqueToken, { ignoreUnknown: true });     }       public getModuleId(metatype: Type&lt;unknown>): string {         let moduleId = this.moduleIdsCashe.get(metatype);         if (moduleId) {             return moduleId;         }         moduleId = uuid();         this.moduleIdsCashe.set(metatype, moduleId);         return moduleId;     }       public getModuleName(metatype: Type&lt;any>): string {         return metatype.name;     } } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043b\u0430\u0441\u0441 Module.  <\/p>\n<p><strong>.\/core\/injector\/module.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { InstanceWrapper } from \".\/instance-wrapper\"; import { randomStringGenerator } from \"..\/..\/common\/utils\/random-string-generator.util\";   export class Module {     private readonly _imports = new Set&lt;Module>();     private readonly _providers = new Map&lt;any, InstanceWrapper>();     private readonly _controllers = new Map&lt;string, InstanceWrapper>();       private _token: string | undefined;       constructor(         private readonly module: any,     ) {}       get providers(): Map&lt;string, any> {         return this._providers;     }       get controllers(): Map&lt;string, any> {         return this._controllers;     }       get metatype() {         return this.module;     }       get token() {         return this._token!;     }       set token(token: string) {         this._token = token;     }       public addProvider(provider: any) {         this._providers.set(             provider.name,             new InstanceWrapper({               name: provider.name,               metatype: provider,               instance: null,             }),         )     }       public addController(controller: any) {         this._controllers.set(             controller.name,             new InstanceWrapper({               name: controller.name,               metatype: controller,               instance: null,             }),         );           this.assignControllerUniqueId(controller);     }       public assignControllerUniqueId(controller: any) {         Object.defineProperty(controller, 'CONTROLLER_ID', {           enumerable: false,           writable: false,           configurable: true,           value: randomStringGenerator(),         });     }       public addRelatedModule(module: Module) {         this._imports.add(module);     } } <\/code><\/pre>\n<p>\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0437\u0434\u0435\u0441\u044c \u0438\u0437\u043b\u0438\u0448\u043d\u0438. \u0412\u0441\u0435, \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442, \u044d\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f, \u0441\u0430\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u0438 \u0435\u0433\u043e \u0442\u043e\u043a\u0435\u043d.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 InstanceWrapper.<\/p>\n<p><strong>.\/core\/injector\/instance-wrapper.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Type } from '..\/..\/common\/interfaces\/type.interface';   export class InstanceWrapper&lt;T = any> {     public readonly name: string;     public metatype: Type&lt;T> | Function;     public instance: any;     public isResolved = false       constructor(metadata: any) {         Object.assign(this, metadata);         this.instance = metadata.instance;         this.metatype = metadata.metatype;         this.name = metadata.name     } } <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a instance \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f null. \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0432 \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435, \u0442\u043e \u043f\u0440\u0438 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d, \u0438 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u0432 \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u0438\u043c \u043c\u044b \u0434\u0430\u043b\u044c\u0448\u0435 \u0438 \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 \u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u041c\u043e\u0434\u0443\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u043c \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0432 \u0432\u0438\u0434\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 Module, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u0432\u0441\u0435 \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0438 \u0445\u0440\u0430\u043d\u044f\u0442 \u0441\u0432\u043e\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 reflect, \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 Map \u0438 Set. <\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043d\u043e\u0432\u0430 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043a\u043b\u0430\u0441\u0441\u0443 NestContainer \u0438 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 initialize  <\/p>\n<pre><code class=\"javascript\">private async initialize(         module: Module,         container: NestContainer,     ) {         const instanceLoader = new InstanceLoader(container)         const dependenciesScanner = new DependenciesScanner(container);           await dependenciesScanner.scan(module);         await instanceLoader.createInstancesOfDependencies();<\/code><\/pre>\n<p>\u043d\u0430 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434 initialize<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u0440\u043e\u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u0438, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0439\u0447\u0430\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 InstanceLoader.<\/p>\n<p><strong>.\/core\/injector\/instance-loader.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { NestContainer } from \".\/container\"; import { Injector } from \".\/injector\"; import { Module } from \".\/module\";   export class InstanceLoader {     private readonly injector = new Injector();       constructor(private readonly container: NestContainer) {}       public async createInstancesOfDependencies() {         const modules = this.container.getModules();           await this.createInstances(modules);     }       \/**      * \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432,      * \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432,      * \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u043e\u043d\u0438 \u0443\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b      * \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c.      *\/     private async createInstances(modules: Map&lt;string, Module>) {         await Promise.all(             [...modules.values()].map(async module => {                 await this.createInstancesOfProviders(module);                 await this.createInstancesOfControllers(module);             })         )     }       private async createInstancesOfProviders(module: Module) {         const { providers } = module;         const wrappers = [...providers.values()];         await Promise.all(             wrappers.map(item => this.injector.loadProvider(item, module)),         )     }       private async createInstancesOfControllers(module: Module) {         const { controllers } = module;         const wrappers = [...controllers.values()];         await Promise.all(             wrappers.map(item => this.injector.loadControllers(item, module)),         )     } } <\/code><\/pre>\n<p>\u0422\u043e\u0436\u0435 \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0412\u0441\u0435, \u0447\u0442\u043e \u043e\u043d\u0430 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 Injector. \u0427\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043a \u043c\u0435\u0442\u043e\u0434\u0443 createInstances, \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432.\u00a0<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043b\u0430\u0441\u0441 Injector, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445, \u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<p><strong>.\/core\/injector\/injector.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Module } from \".\/module\"; import { InstanceWrapper } from '.\/instance-wrapper'; import { Type } from  '..\/..\/common\/interfaces\/type.interface';   export class Injector {       public async loadInstance&lt;T>(         wrapper: InstanceWrapper&lt;T>,         collection: Map&lt;string, InstanceWrapper>,         moduleRef: Module,     ) {         const { name } = wrapper;           const targetWrapper = collection.get(name);         if (!targetWrapper) {             throw Error('TARGET WRAPPER NOT FOUNDED')         }         const callback = async (instances: unknown[]) => {             await this.instantiateClass(                 instances,                 wrapper,                 targetWrapper,             );         }         await this.resolveConstructorParams&lt;T>(             wrapper,             moduleRef,             callback,           );     }       public async loadProvider(         wrapper: any,         moduleRef: Module,     ) {         const providers = moduleRef.providers;         await this.loadInstance&lt;any>(             wrapper,             providers,             moduleRef,         );     }       public async loadControllers(         wrapper: any,         moduleRef: Module,     ) {         const controllers = moduleRef.controllers;         await this.loadInstance&lt;any>(             wrapper,             controllers,             moduleRef,         );     }       \/**      * design:paramtypes \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c reflect      * \u0434\u043b\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043a\u043b\u0430\u0441\u0441\u0430.      * \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0443 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438,      * \u0442\u043e \u043e\u043d\u0438 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430\u043c\u0438.      * callback, \u043a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u0430 loadInstance, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434      * instantiateClass \u0434\u043b\u044f \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432.      *\/     public async resolveConstructorParams&lt;T>(         wrapper: InstanceWrapper&lt;T>,         moduleRef: Module,         callback: (args: unknown[]) => void | Promise&lt;void>,     ) {         const dependencies = Reflect.getMetadata('design:paramtypes', wrapper.metatype)             const resolveParam = async (param: Function, index: number) => {           try {             let providers = moduleRef.providers             const paramWrapper = providers.get(param.name);             return paramWrapper?.instance           } catch (err) {               throw err;           }         };         const instances = dependencies ? await Promise.all(dependencies.map(resolveParam)) : [];         await callback(instances);     }       \/**      * \u0421\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 InstanceLoader,      * \u043a\u0430\u043a metatype, \u0441 \u0435\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430\u043c\u0438,      * \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u044d\u0442\u043e\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0432 instance \u043f\u043e\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 InstanceLoader,      * \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432.      *\/     public async instantiateClass&lt;T = any>(         instances: any[],         wrapper: InstanceWrapper,         targetMetatype: InstanceWrapper,     ): Promise&lt;T> {         const { metatype } = wrapper;           targetMetatype.instance = instances             ? new (metatype as Type&lt;any>)(...instances)             : new (metatype as Type&lt;any>)();                 return targetMetatype.instance;     } } <\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0418\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>\u0421\u0435\u0439\u0447\u0430\u0441 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a NestFactory, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043a \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0443 create.<\/p>\n<pre><code class=\"javascript\">public async create(module: Module) {         const applicationConfig = new ApplicationConfig();         const container = new NestContainer();         await this.initialize(module, container);           const httpServer = new ExpressAdapter()         container.setHttpAdapter(httpServer);         const instance = new NestApplication(             container,             httpServer,             applicationConfig,         );                 return instance;<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0441 \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 ExpressAdapter, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 AbstractHttpAdapter. \u0422\u043e \u0435\u0441\u0442\u044c \u0437\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u043a\u0430\u043a \u0430\u0434\u0430\u043f\u0442\u0435\u0440. \u041f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u043a\u043b\u0430\u0441\u0441 FastifyAdapter \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f fastify \u0432\u043c\u0435\u0441\u0442\u043e express. \u0422\u0430\u043a \u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 nest, \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0435\u043c express \u0438\u0437-\u0437\u0430 \u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c AbstractHttpAdapter.<\/p>\n<p><strong>.\/core\/adapters\/http-adapter.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { HttpServer } from \"..\/..\/common\/interfaces\/http-server.interface\";   export abstract class AbstractHttpAdapter&lt;   TServer = any,   TRequest = any,   TResponse = any > implements HttpServer&lt;TRequest, TResponse> {   protected httpServer: TServer | undefined;     constructor(protected readonly instance: any) {}     public use(...args: any[]) {     return this.instance.use(...args);   }     public get(...args: any[]) {     return this.instance.get(...args);   }     public post(...args: any[]) {     return this.instance.post(...args);   }     public listen(port: any) {     return this.instance.listen(port);   }     public getHttpServer(): TServer {     return this.httpServer as TServer;   }     public setHttpServer(httpServer: TServer) {     this.httpServer = httpServer;   }     public getInstance&lt;T = any>(): T {     return this.instance as T;   }     abstract initHttpServer(): any;   abstract reply(response: any, body: any, statusCode?: number): any;   abstract registerBodyParser(prefix?: string): any; } <\/code><\/pre>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 http \u0441\u0435\u0440\u0432\u0435\u0440\u0430. \u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0443 \u043d\u0430\u0448\u0435\u0433\u043e nest \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0432\u0430 http \u043c\u0435\u0442\u043e\u0434\u0430, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e post \u0438 get.<\/p>\n<p>\u0410 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0430\u0434\u0430\u043f\u0442\u0435\u0440<\/p>\n<pre><code class=\"javascript\">interface HttpServer&lt;TRequest = any, TResponse = any> {     reply(response: any, body: any, statusCode?: number): any;     get(handler: RequestHandler&lt;TRequest, TResponse>): any;     get(path: string, handler: RequestHandler&lt;TRequest, TResponse>): any;     post(handler: RequestHandler&lt;TRequest, TResponse>): any;     post(path: string, handler: RequestHandler&lt;TRequest, TResponse>): any;     listen(port: number | string): any;       getInstance(): any;     getHttpServer(): any;     initHttpServer(): void;     registerBodyParser(): void } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043b\u0430\u0441\u0441 ExpressAdapter  <\/p>\n<p><strong>.\/platform-express\/express.adapter.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { AbstractHttpAdapter } from '..\/core\/adapters'; import { isNil, isObject } from '..\/common\/utils\/shared.utils' import express from 'express'; import * as http from 'http'; import {   json as bodyParserJson,   urlencoded as bodyParserUrlencoded, } from 'body-parser';   export class ExpressAdapter extends AbstractHttpAdapter {       constructor() {       super(express());     }       \/**      * \u042f\u0432\u043b\u044f\u0435\u0442\u0441\u044f response \u043c\u0435\u0442\u043e\u0434\u043e\u043c. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u0433\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.      *\/     public reply(response: any, body: any) {         if (isNil(body)) {           return response.send();         }             return isObject(body) ? response.json(body) : response.send(String(body));     }       \/**      * \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043d\u043e\u043c \u043f\u043e\u0440\u0442\u0435      *\/     public listen(port: any) {         return this.httpServer.listen(port);     }         public registerBodyParser() {       const parserMiddleware = {         jsonParser: bodyParserJson(),         urlencodedParser: bodyParserUrlencoded({ extended: true }),       };       Object.keys(parserMiddleware)         .forEach((parserKey: any) => this.use((parserMiddleware as any)[parserKey]));       }       public initHttpServer() {         this.httpServer = http.createServer(this.getInstance());     } } <\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u043a \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 express. \u0412 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435, \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 super, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 express \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 AbstractHttpAdapter, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b post, get \u0438 use.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0441\u043d\u043e\u0432\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a NestFactory,<\/p>\n<pre><code class=\"javascript\">public async create(module: Module) {         const container = new NestContainer();         await this.initialize(module, container);           const httpServer = new ExpressAdapter()         container.setHttpAdapter(httpServer);         const instance = new NestApplication(             container,             httpServer,         );                 return instance;     } <\/code><\/pre>\n<p>\u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 NestApplication, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c \u0432\u0441\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Nest. \u0418\u043c\u0435\u043d\u043d\u043e \u0438\u0437 \u043d\u0435\u0433\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 listen,  <\/p>\n<pre><code class=\"javascript\">async function bootstrap() {     const app = await NestFactory.create(AppModule);     await app.listen(3000); } <\/code><\/pre>\n<p>\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p><strong>.\/core\/nest-application.ts<\/strong><\/p>\n<pre><code class=\"javascript\">import { HttpServer } from '..\/common\/interfaces\/http-server.interface'; import { Resolver } from '.\/router\/interfaces\/resolver.interface'; import { addLeadingSlash } from '..\/common\/utils\/shared.utils'; import { NestContainer } from '.\/injector\/container'; import { RoutesResolver } from '.\/router\/routes-resolver';   export class NestApplication {     private readonly routesResolver: Resolver;     public httpServer: any;       constructor(         private readonly container: NestContainer,         private readonly httpAdapter: HttpServer,     ) {         this.registerHttpServer();           this.routesResolver = new RoutesResolver(             this.container,         );     }       public registerHttpServer() {         this.httpServer = this.createServer();     }       \/**      * \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e http \u0441\u0435\u0440\u0432\u0435\u0440\u0430      *\/     public createServer&lt;T = any>(): T {         this.httpAdapter.initHttpServer();         return this.httpAdapter.getHttpServer() as T;     }       public async init(): Promise&lt;this> {         this.httpAdapter.registerBodyParser();         await this.registerRouter();         return this;     }       \/**      * \u041c\u0435\u0442\u043e\u0434, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Nest.      * \u041e\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 http \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438      * \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432, \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u0440\u0442\u0435.      *\/     public async listen(port: number | string) {         await this.init();         this.httpAdapter.listen(port);         return this.httpServer;     }       \/**      * \u041c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432,      * \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 http \u043c\u0435\u0442\u043e\u0434\u043e\u0432,      * \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a post \u0438 get.      *\/     public async registerRouter() {         const prefix = ''         const basePath = addLeadingSlash(prefix);         this.routesResolver.resolve(this.httpAdapter, basePath);     } } <\/code><\/pre>\n<p>\u0418 \u044d\u0442\u043e \u043f\u043e\u0434\u0432\u043e\u0434\u0438\u0442 \u043d\u0430\u0441 \u043a \u0440\u043e\u0443\u0442\u0435\u0440\u0430\u043c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u043a \u043a\u043b\u0430\u0441\u0441\u0443 RoutesResolver.<\/p>\n<p><strong>.\/core\/router\/routes-resolver.ts<\/strong><\/p>\n<pre><code class=\"javascript\">import { NestContainer } from '..\/injector\/container'; import { Resolver } from '..\/router\/interfaces\/resolver.interface'; import { MODULE_PATH } from '..\/..\/common\/constants'; import { HttpServer } from '..\/..\/common\/interfaces\/http-server.interface'; import { InstanceWrapper } from '..\/injector\/instance-wrapper'; import { RouterExplorer } from '.\/router-explorer';   export class RoutesResolver implements Resolver {     private readonly routerExplorer: RouterExplorer;       constructor(         private readonly container: NestContainer,       ) {         this.routerExplorer = new RouterExplorer(             this.container,         );     }       \/**      * \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0443\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439      * \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0435 Module,      * \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0435\u0433\u043e \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0432 \u043c\u0435\u0442\u043e\u0434 registerRouters      *\/     public resolve(applicationRef: any, basePath: string): void {         const modules = this.container.getModules();         modules.forEach(({ controllers, metatype }) => {             let path = metatype ? this.getModulePathMetadata(metatype) : undefined;             path = path ? basePath + path : basePath;             this.registerRouters(controllers, metatype.name, path, applicationRef);         });     }       \/**      * \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432 \u043c\u043e\u0434\u0443\u043b\u0435, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 explore      * \u043a\u043b\u0430\u0441\u0441\u0430 routerExplorer, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443      * \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432      *\/     public registerRouters(         routes: Map&lt;string, InstanceWrapper&lt;any>>,         moduleName: string,         basePath: string,         applicationRef: HttpServer,       ) {         routes.forEach(instanceWrapper => {           const { metatype } = instanceWrapper;               \/\/ \u041d\u0430\u0445\u043e\u0434\u0438\u0442 \u043f\u0443\u0442\u044c \u0434\u043b\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 @Controller('cats')           const paths = this.routerExplorer.extractRouterPath(             metatype as any,             basePath,           );               \/\/ \u0415\u0441\u043b\u0438 \u043f\u0443\u0442\u044c \u0431\u044b\u043b \u043f\u0435\u0440\u0435\u0434\u0430\u043d \u043a\u0430\u043a @Controllers('cats'), \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437.           \/\/ \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e reflect \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432           paths.forEach(path => {             this.routerExplorer.explore(               instanceWrapper,               moduleName,               applicationRef,               path,             );           });         });       }       private getModulePathMetadata(metatype: object): string | undefined {         return Reflect.getMetadata(MODULE_PATH, metatype);     } } <\/code><\/pre>\n<p>\u041a\u043e\u0434 \u0432\u044b\u0448\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0431\u044b\u043b \u0432\u044b\u0437\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 explore \u043a\u043b\u0430\u0441\u0441\u0430 RouterExplorer. \u041a\u043b\u0430\u0441\u0441 RouterExplorer \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432. \u041e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 http \u043c\u0435\u0442\u043e\u0434\u044b, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0445 callbacks, \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u0442 \u044d\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u043a \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0443 \u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f, \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \u0438 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p><strong>.\/core\/router\/routes-explorer.ts<\/strong><\/p>\n<pre><code class=\"javascript\">import { NestContainer } from '..\/injector\/container'; import { RouterProxyCallback } from '.\/router-proxy'; import { addLeadingSlash } from '..\/..\/common\/utils\/shared.utils'; import { Type } from '..\/..\/common\/interfaces\/type.interface'; import { Controller } from '..\/..\/common\/interfaces\/controller.interface'; import { PATH_METADATA, METHOD_METADATA, ROUTE_ARGS_METADATA, PARAMTYPES_METADATA } from '..\/..\/common\/constants'; import { RequestMethod } from '..\/..\/common\/enums\/request-method.enum'; import { HttpServer } from '..\/..\/common\/interfaces\/http-server.interface'; import { InstanceWrapper } from '..\/injector\/instance-wrapper'; import { RouterMethodFactory } from '..\/helpers\/router-method-factory'; import {   isConstructor,   isFunction,   isString, } from '..\/..\/common\/utils\/shared.utils'; import { RouteParamtypes } from '..\/..\/common\/enums\/route-paramtypes.enum';     export interface RoutePathProperties {     path: string[];     requestMethod: RequestMethod;     targetCallback: RouterProxyCallback;     methodName: string;   }   export class RouterExplorer {     private readonly routerMethodFactory = new RouterMethodFactory();       constructor (         private readonly container: NestContainer,     ) {     }           public explore&lt;T extends HttpServer = any>(         instanceWrapper: InstanceWrapper,         module: string,         router: T,         basePath: string,       ) {         const { instance } = instanceWrapper;         const routePaths: RoutePathProperties[] = this.scanForPaths(instance);                 \/\/ \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432         (routePaths || []).forEach((pathProperties: any) => {             this.applyCallbackToRouter(               router,               pathProperties,               instanceWrapper,               module,               basePath,             );         })     }       \/**      * \u041c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0443 \u043d\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b      * \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0443\u0442\u044f\u043c\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u0435\u0442\u043e\u0434, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439      * \u043d\u0430\u0432\u0435\u0448\u0435\u043d \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 @post('add_to_database').      * \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430      * \u0441 \u043f\u0443\u0442\u044f\u043c\u0438, \u0442\u0435\u043b\u0430\u043c\u0438 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043c\u0435\u0442\u043e\u0434\u043e\u043c request \u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435      * \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 exploreMethodMetadata      *\/     public scanForPaths(         instance: Controller,       ): RoutePathProperties[] {         const instancePrototype = Object.getPrototypeOf(instance);         let methodNames = Object.getOwnPropertyNames(instancePrototype);           const isMethod = (prop: string) => {           const descriptor = Object.getOwnPropertyDescriptor(instancePrototype, prop);           if (descriptor?.set || descriptor?.get) {             return false;           }           return !isConstructor(prop) &amp;&amp; isFunction(instancePrototype[prop]);         };             return methodNames.filter(isMethod).map(method => this.exploreMethodMetadata(instance, instancePrototype, method))     }       \/**      * \u0414\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430,      * \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 scanForPaths      *\/     public exploreMethodMetadata(       instance: Controller,       prototype: object,       methodName: string,     ): RoutePathProperties {       const instanceCallback = (instance as any)[methodName];       const prototypeCallback = (prototype as any)[methodName];       const routePath = Reflect.getMetadata(PATH_METADATA, prototypeCallback);         const requestMethod: RequestMethod = Reflect.getMetadata(         METHOD_METADATA,         prototypeCallback,       );       const path = isString(routePath)         ? [addLeadingSlash(routePath)]         : routePath.map((p: string) => addLeadingSlash(p));       return {         path,         requestMethod,         targetCallback: instanceCallback,         methodName,       };     }       private applyCallbackToRouter&lt;T extends HttpServer>(         router: T,         pathProperties: RoutePathProperties,         instanceWrapper: InstanceWrapper,         moduleKey: string,         basePath: string,       ) {         const {           path: paths,           requestMethod,           targetCallback,           methodName,         } = pathProperties;         const { instance } = instanceWrapper;         \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 http \u043c\u0435\u0442\u043e\u0434         const routerMethod = this.routerMethodFactory           .get(router, requestMethod)           .bind(router);             \/\/ \u0421\u043e\u0437\u0434\u0430\u0435\u0442 callback \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430         const handler = this.createCallbackProxy(           instance,           targetCallback,           methodName,         );             \/\/ \u0415\u0441\u043b\u0438 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a @Post('add_to_database'),         \/\/ \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0443\u0442\u0438.         paths.forEach(path => {           const fullPath = this.stripEndSlash(basePath) + path;           \/\/ \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0443\u0435\u0442 http \u043c\u0435\u0442\u043e\u0434. \u0421\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0443\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430, \u0438 \u0435\u0433\u043e callback,           \/\/ \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u041e\u0442\u0432\u0435\u0442 \u0436\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f reply \u043c\u0435\u0442\u043e\u0434\u043e\u043c,           \/\/ \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 ExpressAdapter           routerMethod(this.stripEndSlash(fullPath) || '\/', handler);         });     }       public stripEndSlash(str: string) {       return str[str.length - 1] === '\/' ? str.slice(0, str.length - 1) : str;     }       public createCallbackProxy(       instance: Controller,       callback: (...args: any[]) => unknown,       methodName: string,     ) {       \/\/ \u0414\u043e\u0441\u0442\u0430\u0435\u0442 \u043a\u043b\u044e\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0440\u0430\u043d\u0435\u0435 \u0432 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u0445 @Body() \u0438 @Param()       const metadata = Reflect.getMetadata(ROUTE_ARGS_METADATA, instance.constructor, methodName) || {};       const keys = Object.keys(metadata);       const argsLength = Math.max(...keys.map(key => metadata[key].index)) + 1             \/\/ \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 request, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0442\u0435\u043b\u043e \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430.       const paramsOptions = this.exchangeKeysForValues(keys, metadata);         const fnApplyParams = this.resolveParamsOptions(paramsOptions)       const handler = &lt;TRequest, TResponse>(         args: any[],         req: TRequest,         res: TResponse,         next: Function,       ) => async () => {         \/\/ \u0442\u0430\u043a \u043a\u0430\u043a args \u044d\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442, \u0430 \u043d\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f,         \/\/ \u0442\u043e \u043e\u043d \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u0430 \u043d\u0435 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e,         \/\/ \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f, \u0438 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 fnApplyParams,         \/\/ \u0432 args \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 request         fnApplyParams &amp;&amp; (await fnApplyParams(args, req, res, next));         \/\/ \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430,         \/\/ \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u0437 request,         \/\/ \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c, \u043a\u0430\u043a \u0438 \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043e         return callback.apply(instance, args);       };       const targetCallback = async &lt;TRequest, TResponse>(           req: TRequest,           res: TResponse,           next: Function,         ) => {           \/\/ \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f undefined \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438           \/\/ \u0438\u0437 request           const args = Array.apply(null, { argsLength } as any).fill(undefined);           \/\/ result \u044d\u0442\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0441 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432           \/\/ \u0438\u0437 request           const result = await handler(args, req, res, next)()           const applicationRef = this.container.getHttpAdapterRef()           if(!applicationRef) {             throw new Error(`Http server not created`)           }           return await applicationRef.reply(res, result);         }       return async &lt;TRequest, TResponse>(         req: TRequest,         res: TResponse,         next: () => void,       ) => {         try {           await targetCallback(req, res, next);         } catch (e) {           throw e         }       };     }       \/**      * extractValue \u0437\u0434\u0435\u0441\u044c \u044d\u0442\u043e \u043c\u0435\u0442\u043e\u0434 exchangeKeyForValue.      * \u0418 \u0435\u043c\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f request, \u0434\u043b\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430      *\/     public resolveParamsOptions(paramsOptions: any) {       const resolveFn = async (args: any, req: any, res: any, next: any) => {         const resolveParamValue = async (param: any) => {           const { index, extractValue } = param;           const value = extractValue(req, res, next);           args[index] = value         }         await Promise.all(paramsOptions.map(resolveParamValue));       }       return paramsOptions &amp;&amp; paramsOptions.length ? resolveFn : null;     }       \/**      * \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u043a\u043b\u044e\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e      * \u043c\u0435\u0442\u043e\u0434\u0430 exchangeKeyForValue, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0430\u043d\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435,      * \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0440\u0430\u043d\u0435\u0435 \u0432 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u0445 @Body() \u0438 @Param(),      * \u0438\u0437 request.      *\/     public exchangeKeysForValues(       keys: string[],       metadata: Record&lt;number, any>,     ): any[] {       return keys.map((key: any) => {         const { index, data } = metadata[key];         const numericType = Number(key.split(':')[0]);         const extractValue = &lt;TRequest, TResponse>(           req: TRequest,           res: TResponse,           next: Function,         ) =>           this.exchangeKeyForValue(numericType, data, {             req,             res,             next,         });         return { index, extractValue, type: numericType, data }       })     }       \/**      * \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0447\u0435\u043c\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u043b\u044e\u0447 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u0435\u043b\u0443 \u0438\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430.      * \u042d\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430\u0445 @Body() \u0438 @Param().      * \u0418 \u0442\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 api \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d, \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f      * \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0438\u0445 \u0438\u0437 request, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u044b.      *\/     public exchangeKeyForValue&lt;       TRequest extends Record&lt;string, any> = any,       TResponse = any,       TResult = any     >(       key: RouteParamtypes | string,       data: string | object | any,       { req, res, next }: { req: TRequest; res: TResponse; next: Function },     ): TResult | null {       switch (key) {         case RouteParamtypes.BODY:           return data &amp;&amp; req.body ? req.body[data] : req.body;         case RouteParamtypes.PARAM:           return data ? req.params[data] : req.params;         default:           return null;       }     }       public extractRouterPath(metatype: Type&lt;Controller>, prefix = ''): string[] {         let path = Reflect.getMetadata(PATH_METADATA, metatype);             if (Array.isArray(path)) {           path = path.map(p => prefix + addLeadingSlash(p));         } else {           path = [prefix + addLeadingSlash(path)];         }             return path.map((p: string) => addLeadingSlash(p));     } } <\/code><\/pre>\n<p>\u0427\u0442\u043e \u043a \u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 applyCallbackToRouter \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f http \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 RouterMethodFactory, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0438\u043c\u0435\u0435\u0442 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434<\/p>\n<p><strong>.\/core\/helpers\/router-method-factory.ts<\/strong><\/p>\n<pre><code class=\"javascript\">import { HttpServer } from '..\/..\/common\/interfaces\/http-server.interface'; import { RequestMethod } from '..\/..\/common\/enums\/request-method.enum';   export class RouterMethodFactory {   public get(target: HttpServer, requestMethod: RequestMethod): Function {     switch (requestMethod) {       case RequestMethod.POST:         return target.post;       default: {         return target.get;       }     }   } } <\/code><\/pre>\n<p>\u0427\u0442\u043e \u0436. \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0449\u0435 \u0437\u0434\u0435\u0441\u044c, \u043f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e! \u041c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u0441\u0435 \u044f\u0434\u0440\u043e \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0438\u043d\u0438 Nest \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430. \u0422\u0435\u043f\u0435\u0440\u044c, \u0432\u0441\u0435, \u0447\u0442\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c, \u044d\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0438 \u043f\u0438\u0448\u0435\u043c Nest \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 @Module(), \u0438 \u0441\u043f\u0435\u0440\u0432\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/p>\n<pre><code class=\"javascript\">import { Module } from '@nestjs\/common'; import { CatsController } from '.\/cats.controller'; import { CatsService } from '.\/cats.service';   @Module({   controllers: [CatsController],   providers: [CatsService], }) export class CatsModule {} <\/code><\/pre>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430, \u0442\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0435\u0433\u043e.<\/p>\n<p><strong>.\/common\/decorators\/module.decorator.ts<\/strong><\/p>\n<pre><code class=\"javascript\">import { MODULE_METADATA as metadataConstants } from '..\/constants';   const metadataKeys = [   metadataConstants.IMPORTS,   metadataConstants.EXPORTS,   metadataConstants.CONTROLLERS,   metadataConstants.PROVIDERS, ];   \/**  * \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b,  * \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 metadataKeys  *\/ export function validateModuleKeys(keys: string[]) {   const validateKey = (key: string) => {     if (metadataKeys.includes(key)) {       return;     }     throw new Error(`NOT INVALID KEY: ${key}`);   };   keys.forEach(validateKey); }   \/**  * \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 Reflect.  * \u0413\u0434\u0435 property \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438,  * \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 controllers. \u0418\u043c\u0435\u043d\u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443,  * \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0441\u043b\u0435.  *\/ export function Module(metadata: any): ClassDecorator {   const propsKeys = Object.keys(metadata);   validateModuleKeys(propsKeys);     return (target: Function) => {     for (const property in metadata) {       if (metadata.hasOwnProperty(property)) {         Reflect.defineMetadata(property, (metadata as any)[property], target);       }     }   }; } <\/code><\/pre>\n<p>\u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u043e\u0434\u043d\u0430 \u0438\u0437 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 Nest.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 @Controller(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u0432\u0441\u0435, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442, \u044d\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0443\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u0432\u0435\u0434\u044c \u0441\u0430\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0443\u0436\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d \u0432 Reflect \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p><strong>.\/common\/decorators\/controller.decorator.ts<\/strong><\/p>\n<pre><code class=\"javascript\">import { PATH_METADATA } from \"..\/constants\"; import { isUndefined } from \"..\/utils\/shared.utils\";   export function Controller(   prefix?: string, ): ClassDecorator {   const defaultPath = '\/';     const path = isUndefined(prefix) ? defaultPath : prefix     return (target: object) => {     Reflect.defineMetadata(PATH_METADATA, path, target);   }; } <\/code><\/pre>\n<p>\u041f\u043e\u043c\u043d\u0438\u0442\u0435 \u043f\u0440\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 @Injectable(), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u043a\u043e\u0431\u044b \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440? \u041a\u0430\u043a \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u043e\u043d \u043b\u0438\u0448\u044c \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u041a\u043b\u0430\u0441\u0441 \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440, \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 providers \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f. \u0418 \u0445\u043e\u0442\u044c \u043c\u044b \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430, \u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u0442\u044b, \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u044d\u0442\u043e\u0442 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440.<\/p>\n<p><strong>.\/common\/decorators\/injectable.decorator.ts<\/strong><\/p>\n<pre><code class=\"javascript\">import { SCOPE_OPTIONS_METADATA } from '..\/constants';   export enum Scope {     DEFAULT,     TRANSIENT,     REQUEST, }   export interface ScopeOptions {     scope?: Scope; }   export type InjectableOptions = ScopeOptions;   export function Injectable(options?: InjectableOptions): ClassDecorator {     return (target: object) => {       Reflect.defineMetadata(SCOPE_OPTIONS_METADATA, options, target);     }; } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0435\u0433\u043e \u0447\u0435\u0442\u044b\u0440\u0435 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e @Body() \u0438 @Param(), \u0438 \u0434\u043b\u044f http \u043c\u0435\u0442\u043e\u0434\u043e\u0432, @Post() \u0438 @Get().<\/p>\n<p>\u0421\u043f\u0435\u0440\u0432\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0435\u0440\u0432\u044b\u0435 \u0434\u0432\u0430.<\/p>\n<p><strong>.\/common\/decorators\/route-params.decorator.ts<\/strong><\/p>\n<pre><code class=\"javascript\">import { ROUTE_ARGS_METADATA } from \"..\/constants\"; import { RouteParamtypes } from \"..\/enums\/route-paramtypes.enum\"; import { isNil, isString } from \"..\/utils\/shared.utils\";   \/**  * \u0417\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b  * \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.  *\/ const createPipesRouteParamDecorator = (paramtype: RouteParamtypes) => (     data?: any,   ): ParameterDecorator => (target, key, index) => {     const hasParamData = isNil(data) || isString(data);     const paramData = hasParamData ? data : undefined;     const args =       Reflect.getMetadata(ROUTE_ARGS_METADATA, target.constructor, key) || {};       \/\/ \u0413\u0434\u0435 paramtype \u044d\u0442\u043e body \u0438\u043b\u0438 param, \u0430 index \u0435\u0433\u043e     \/\/ \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440,     \/\/ \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0437 request     Reflect.defineMetadata(       ROUTE_ARGS_METADATA,       {         ...args,         [`${paramtype}:${index}`]: {           index,           data: paramData,         },       },       target.constructor,       key,     ); };   export function Body(     property?: string,   ): ParameterDecorator {     return createPipesRouteParamDecorator(RouteParamtypes.BODY)(       property,     ); }   export function Param(     property?: string,   ): ParameterDecorator {     return createPipesRouteParamDecorator(RouteParamtypes.PARAM)(       property,     ); } <\/code><\/pre>\n<p>\u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b post \u0438 get, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 Reflect \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u0438\u0445 \u043f\u0443\u0442\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p><strong>.\/common\/decorators\/request-mapping.decorator.ts<\/strong><\/p>\n<pre><code class=\"javascript\">import { METHOD_METADATA, PATH_METADATA } from '..\/constants'; import { RequestMethod } from '..\/enums\/request-method.enum';   export interface RequestMappingMetadata {   path?: string | string[];   method?: RequestMethod; }   const defaultMetadata = {   [PATH_METADATA]: '\/',   [METHOD_METADATA]: RequestMethod.GET, };   export const RequestMapping = (   metadata: RequestMappingMetadata = defaultMetadata, ): MethodDecorator => {   const pathMetadata = metadata[PATH_METADATA];   const path = pathMetadata &amp;&amp; pathMetadata.length ? pathMetadata : '\/';   const requestMethod = metadata[METHOD_METADATA] || RequestMethod.GET;     return (     target: object,     key: string | symbol,     descriptor: TypedPropertyDescriptor&lt;any>,   ) => {     Reflect.defineMetadata(PATH_METADATA, path, descriptor.value);     Reflect.defineMetadata(METHOD_METADATA, requestMethod, descriptor.value);     return descriptor;   }; };   const createMappingDecorator = (method: RequestMethod) => (   path?: string | string[], ): MethodDecorator => {   return RequestMapping({     [PATH_METADATA]: path,     [METHOD_METADATA]: method,   }); };   \/**  * \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 (\u043c\u0435\u0442\u043e\u0434) Decorator. \u041d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b HTTP POST \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438.  *  * @publicApi  *\/ export const Post = createMappingDecorator(RequestMethod.POST);   \/**  * \u041e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 (\u043c\u0435\u0442\u043e\u0434) Decorator. \u041d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b HTTP GET \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438.  *  * @publicApi  *\/ export const Get = createMappingDecorator(RequestMethod.GET); <\/code><\/pre>\n<p>\u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430, \u043d\u0430\u0448 \u043c\u0438\u043d\u0438 Nest \u0433\u043e\u0442\u043e\u0432!\u00a0<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e project-view \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0439 nest, \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/p>\n<p><strong>.\/project-view\/main.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { NestFactory } from '..\/core'; import { AppModule } from '.\/app.module';   async function bootstrap() {   const app = await NestFactory.create(AppModule);   await app.listen(3000); } bootstrap();<\/code><\/pre>\n<p><strong>.\/project-view\/app.controller.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Controller, Get, Post, Body, Param } from '..\/common'; import { AppService } from '.\/app.service';   @Controller() export class AppController {   constructor(private readonly appService: AppService) {}     @Get()   getHello(): string {     return this.appService.getHello();   }     @Post('body\/:id')   recieveBody(@Body() data: any, @Param('id') id: string) {     return 'body: ' + data.data + ' has been received and id: ${id}';   } } <\/code><\/pre>\n<p><strong>.\/project-view\/app.service.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Injectable } from '..\/common';   @Injectable() export class AppService {   getHello(): string {     return 'Hello World!';   } } <\/code><\/pre>\n<p><strong>.\/project-view\/app.module.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Module } from '..\/common'; import { AppController } from '.\/app.controller'; import { AppService } from '.\/app.service';   @Module({   imports: [],   controllers: [AppController],   providers: [AppService], }) export class AppModule {}<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c typescript \u043f\u0440\u043e\u0435\u043a\u0442, \u0441\u043e\u0437\u0434\u0430\u0432 tsconfig.json \u0444\u0430\u0439\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b <\/p>\n<pre><code class=\"bash\">tsc --init<\/code><\/pre>\n<p>\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a-\u0442\u043e \u0432\u043e\u0442 \u0442\u0430\u043a  <\/p>\n<pre><code class=\"json\">{   \"compilerOptions\": {     \"target\": \"es2017\",     \"experimentalDecorators\": true,     \"emitDecoratorMetadata\": true,     \"module\": \"commonjs\",     \"outDir\": \".\/\",     \"esModuleInterop\": true,     \"forceConsistentCasingInFileNames\": true,     \"strict\": true,     \"skipLibCheck\": true,   },   \"include\": [\"packages\/**\/*\", \"integration\/**\/*\", \".\/core\/\", \".\/common\/\", \".\/project-view\/\", \".\/platform-express\/\"],   \"exclude\": [\"node_modules\", \"**\/*.spec.ts\"] } <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c typescript \u0432 js \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b  <\/p>\n<pre><code class=\"bash\">tsc --build<\/code><\/pre>\n<p>\u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f  <\/p>\n<pre><code class=\"bash\">cd project-view<\/code><\/pre>\n<p>\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432\u0445\u043e\u0434\u043d\u043e\u0439 \u0444\u0430\u0439\u043b  <\/p>\n<pre><code class=\"bash\">node main.js<\/code><\/pre>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0447\u0435\u0440\u0435\u0437 postman, \u0438 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441 body \u0438 params \u0434\u043b\u044f post \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 Nest \u0447\u0443\u0442\u044c \u043b\u0443\u0447\u0448\u0435 \ud83d\ude42<\/p>\n<p><a href=\"https:\/\/github.com\/Nikitala0014\/mini-nest\" rel=\"noopener noreferrer nofollow\">\u0413\u0438\u0442\u0445\u0430\u0431 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441\u043e \u0432\u0441\u0435\u043c \u043a\u043e\u0434\u043e\u043c<\/a> <\/p>\n<p>\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438:<\/p>\n<p>\u041f\u043e\u0447\u0442\u0430 &#8212; <a href=\"mailto:keith.la.00@gmail.com\" rel=\"noopener noreferrer nofollow\"><u>keith.la.00@gmail.com<\/u><\/a><\/p>\n<p>Telegram &#8212; @NLavrenov00<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/651139\/\"> https:\/\/habr.com\/ru\/post\/651139\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0426\u0438\u0442\u0430\u0442\u0430 \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:  <\/p>\n<blockquote>\n<p>Nest \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u044b\u0441\u043e\u043a\u043e\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u044b\u0435, \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0435, \u0441\u043b\u0430\u0431\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0438 \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0432 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u0435\u043d\u0430 Angular.  <\/p>\n<\/blockquote>\n<p>Nest \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f &#8212; dependency injection. \u041c\u044b \u0443\u0432\u0438\u0434\u0438\u043c \u043a\u0430\u043a \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 Nest \u0438 \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0432\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f nestjs \u0438\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438:<\/p>\n<p><strong>main.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { NestFactory } from \"@nestjs\/core\"; import { AppModule } from \".\/app.module\";   async function bootstrap() {     const app = await NestFactory.create(AppModule);     await app.listen(3000); }   bootstrap();<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a. <em>NestFactory<\/em> \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 nest \u0441 \u0447\u0435\u0433\u043e \u0432\u0441\u0435 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f. \u0415\u0433\u043e \u043c\u0435\u0442\u043e\u0434 <em>create <\/em>\u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 \u0434\u0435\u0440\u0435\u0432\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f AppModule, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0432 \u0432\u0438\u0434\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432, \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439, \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 \u044d\u0442\u043e \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440. \u041f\u043e\u0441\u043b\u0435 \u0441\u043a\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u041f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 listen \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435, \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c\u0438 \u0432\u044b\u0437\u043e\u0432\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u0436\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435.\u00a0<\/p>\n<p>\u041a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043c\u044b \u043f\u0440\u0438\u0434\u0435\u043c \u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435, \u0430 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a\u0438\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u0438 \u043c\u043e\u0434\u0443\u043b\u044c.<\/p>\n<p><strong>app.controller.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Controller, Get, Post, Body, Param } from 'nestjs\/common'; import { AppService } from '.\/app.service';   @Controller() export class AppController {   constructor(private readonly appService: AppService) {}     @Get()   getHello(): string {     return this.appService.getHello();   }     @Post('body\/:id')   recieveBody(@Body() data: { recieveData: string }, @Param('id') id: string) {     return 'body: ' + data.recieveData + ' has been recieved and id: ' + 'id';   } } <\/code><\/pre>\n<p>\u0427\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435, \u0442\u0430\u043a \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u043c\u0435\u0442\u043e\u0434\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0432\u0435\u0448\u0438\u0432\u0430\u0435\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u044b \u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f callbacks \u0434\u043b\u044f \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u0432. \u041c\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438 \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e, \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0432\u0441\u0435, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c, \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435. \u041c\u044b \u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0430 \u043d\u0435 \u043a\u0430\u043a, \u0442\u043e \u0435\u0441\u0442\u044c, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 Nest, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0437\u0434\u0435\u0441\u044c \u0435\u0441\u0442\u044c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c AppService, \u043a\u043e\u0442\u043e\u0440\u0443\u044e Nest \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u0442 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0414\u043b\u044f \u043d\u0430\u0441 \u0436\u0435, \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 Nest \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u0442\u0438\u043f\u0443, \u0438 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e.<\/p>\n<p><strong>app.service.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Injectable } from 'nestjs\/common';   @Injectable() export class AppService {   getHello(): string {     return 'Hello World!';   } } <\/code><\/pre>\n<p>\u0417\u0434\u0435\u0441\u044c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 Injectable, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 AppService \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 Nest, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u0430\u0432\u0434\u043e\u0439. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u0435, \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442, \u044d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0436\u0438\u0437\u043d\u0438 \u043a\u043b\u0430\u0441\u0441\u0430. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d\u043e \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u0436\u0438\u0437\u043d\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438 \u0441\u0430\u043c Nest \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c, \u0442\u043e Injectable \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c. \u0410 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 Nest \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 providers \u043c\u043e\u0434\u0443\u043b\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.  <\/p>\n<p><strong>app.module.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Module } from 'nestjs\/common'; import { AppController } from '.\/app.controller'; import { AppService } from '.\/app.service';   @Module({   imports: [],   controllers: [AppController],   providers: [AppService], }) export class AppModule {}<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a <strong>main.ts<\/strong>, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c <strong>NestFactory<\/strong> \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c\u0441\u044f, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0432\u0440\u043e\u0434\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 null \u0438 \u0442.\u0434., \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b \u0431\u0443\u0434\u0443\u0442 \u043e\u043f\u0443\u0449\u0435\u043d\u044b \u0432 \u0441\u0442\u0430\u0442\u044c\u0435, \u043d\u043e \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435.<\/p>\n<p><strong>.\/core\/nest-factory.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { NestApplication } from \".\/nest-application\"; import { NestContainer } from \".\/injector\/container\"; import { InstanceLoader } from \".\/injector\/instance-loader\"; import { DependenciesScanner } from \".\/scanner\"; import { ExpressAdapter } from '..\/platform-express\/express.adapter';   export class NestFactoryStatic {     public async create(module: any) {         const container = new NestContainer();   \/\/ \u0421\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b   \/\/ \u0438 \u0432\u043d\u0435\u0434\u0440\u044f\u0435\u0442 \u0438\u0445         await this.initialize(module, container);     \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442 http \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0440\u043e\u0443\u0442\u0435\u0440\u044b    \/\/ \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 instance.listen(3000)         const httpServer = new ExpressAdapter()         container.setHttpAdapter(httpServer);         const instance = new NestApplication(             container,             httpServer,             applicationConfig,         );                 return instance;     }       private async initialize(         module: any,         container: NestContainer,     ) {         const instanceLoader = new InstanceLoader(container)         const dependenciesScanner = new DependenciesScanner(container);           await dependenciesScanner.scan(module);         await instanceLoader.createInstancesOfDependencies();     } }     \/**  * \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 NestFactory \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.  *  * ### \u0423\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f  *  * \u041f\u0435\u0440\u0435\u0434\u0430\u0439\u0442\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0439 *root module* (\u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c) \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f  * \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043c\u043e\u0434\u0443\u043b\u044f. \u041f\u043e \u0441\u043e\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044e \u043e\u043d \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f  * `AppModule`. \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f Nest \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u0433\u0440\u0430\u0444  * \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430  * \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.  *  * @publicApi  *\/ export const NestFactory = new NestFactoryStatic(); <\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a. \u0418\u0437 \u043a\u043e\u0434\u0430 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0441\u043f\u0435\u0440\u0432\u0430 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0430 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f http \u0441\u0435\u0440\u0432\u0435\u0440. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0435\u0439\u0447\u0430\u0441 \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 DependenciesScanner. \u041e\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439, \u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0443\u0433\u0430\u0442\u044c\u0441\u044f, \u0432\u0435\u0434\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e, \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0442\u0430\u043c \u043d\u0435\u0442.  <\/p>\n<p><strong>.\/core\/scanner.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { MODULE_METADATA } from \"..\/common\/constants\"; import { NestContainer } from \".\/injector\/container\"; import 'reflect-metadata'; import { Module } from \".\/injector\/module\";   export class DependenciesScanner {       constructor(private readonly container: NestContainer) {}       public async scan(module: any) {         \/\/ \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440         await this.scanForModules(module);         \/\/ \u041f\u043e\u0441\u043b\u0435 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a Controllers \u0438 Providers         await this.scanModulesForDependencies();     }       public async scanForModules(module: any) {         \/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440         const moduleInstance = await this.insertModule(module);         \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 imports.         \/\/ \u0422\u0430\u043a \u043a\u0430\u043a AppModule - \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u0442\u043e \u043e\u0442 \u043d\u0435\u0433\u043e \u0438\u0434\u0435\u0442 \u0434\u0435\u0440\u0435\u0432\u043e \u043c\u043e\u0434\u0443\u043b\u0435\u0439.         const innerModules = [...this.reflectMetadata(moduleInstance, MODULE_METADATA.IMPORTS)];           \/\/ \u041f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043d\u0438\u043c\u0438 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435.         \/\/ \u0422\u043e \u0435\u0441\u0442\u044c, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f.         for (const [index, innerModule] of innerModules.entries()) {             await this.scanForModules(innerModule)         }           return moduleInstance     }       \/**      * \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440      *\/     public async insertModule(module: any) {         return this.container.addModule(module);     }         \/**      * \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432\u0441\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u0438 \u0441\u043a\u0430\u043d\u0438\u0440\u0443\u0435\u0442 \u0443 \u043d\u0438\u0445      * \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 reflect \u043e\u0431\u044a\u0435\u043a\u0442\u0435.      *\/     public async scanModulesForDependencies() {         const modules: Map&lt;string, Module> = this.container.getModules();           for (const [token, { metatype }] of modules) {             await this.reflectAndAddImports(metatype, token);             this.reflectAndAddProviders(metatype, token);             this.reflectAndAddControllers(metatype, token);         }     }       public async reflectAndAddImports(         module: any,         token: string,     ) {         \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e imports \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440         const modules = this.reflectMetadata(module, MODULE_METADATA.IMPORTS);         for (const related of modules) {             await this.container.addImport(related, token);         }     }       public reflectAndAddProviders(         module: any,         token: string,     ) {         \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e providers \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440         const providers = this.reflectMetadata(module, MODULE_METADATA.PROVIDERS);         providers.forEach((provider: any) =>             this.container.addProvider(provider, token),         );     }       public reflectAndAddControllers(module: any, token: string) {         \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e controllers \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440         const controllers = this.reflectMetadata(module, MODULE_METADATA.CONTROLLERS);         controllers.forEach((controller: any) =>             this.container.addController(controller, token),         );     }       \/**      * \u041c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u0438 \u043a\u043b\u044e\u0447\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.      *\/     public reflectMetadata(metatype: any, metadataKey: string) {         return Reflect.getMetadata(metadataKey, metatype) || [];     } } <\/code><\/pre>\n<p>\u0421\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043a\u043e\u0434, \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043c\u043e\u0434\u0443\u043b\u0438 \u0438 \u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0438 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0434\u0432\u0443\u043c \u043a\u043b\u0430\u0441\u0441\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u0437\u0434\u0435\u0441\u044c &#8212; NestContainer \u0438 Module. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0438 \u043a\u0430\u043a \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u043a\u043b\u0430\u0441\u0441\u0430 Module, \u0438 \u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b, \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 Module, \u0432 \u0442\u0430\u043a\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043a\u0430\u043a Map \u0438 Set. \u0410 \u0441\u0430\u043c\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 InstanceWrapper.\u00a0<\/p>\n<p>\u041a\u043b\u0430\u0441\u0441\u044b Module \u0438 InstanceWrapper \u0432 \u043d\u0430\u0448\u0435\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432\u0442\u043e\u0440\u043e\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440.<\/p>\n<p><strong>.\/core\/injector\/container.ts<\/strong>  <\/p>\n<pre><code class=\"javascript\">import { Module } from \".\/module\"; import { ModuleTokenFactory } from \".\/module-token-factory\"; import { AbstractHttpAdapter } from \"..\/adapters\";   export class NestContainer {     private readonly modules<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-329467","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=329467"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/329467\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}