{"id":333766,"date":"2022-05-28T15:00:16","date_gmt":"2022-05-28T15:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=333766"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=333766","title":{"rendered":"<span>\u0421\u0442\u0440\u043e\u0438\u043c REST API \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Nest.js \u0438 Swagger<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0414\u0440\u0443\u0437\u044c\u044f, \u0432\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!\u00a0<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0435\u0439 \u0438 \u0432\u043e\u0442 \u0443\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c frontend-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439. <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043e\u043f\u0438\u0448\u0443 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e RESTfull API. \u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044f \u043f\u0438\u0441\u0430\u043b \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Typescript, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u043b\u043e \u0431\u044b \u043c\u043d\u0435 \u0436\u0438\u0437\u043d\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u043e\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0438 \u0432\u0430\u043c!<\/p>\n<h3>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u0438  <\/h3>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0433\u0438\u043f\u043e\u0442\u0435\u0437 \u043f\u0440\u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0441\u0440\u043e\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043c\u043d\u0435 \u0434\u043e\u0432\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0434 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u043e\u043c. \u042d\u0442\u043e \u0431\u044b\u043b\u043e backend-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 RESTfull API \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 Nest.js \u0438 Swagger.   <\/p>\n<h4>\u0412\u044b\u0431\u043e\u0440 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 <\/h4>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0441\u0442\u0435\u043a\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Node.js, \u0442\u0430\u043a \u043a\u0430\u043a \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 RESTfull API \u043b\u0435\u0433\u043b\u0430 \u043d\u0430 \u043f\u043b\u0435\u0447\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b frontend-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Angular. <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 Nest.js \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c\u0438 \u0432 Angular. \u0417\u0434\u0435\u0441\u044c \u0438 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 \u043d\u0430\u043c Dependency Injection, RxJS, Typescript, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 \u043c\u043e\u0449\u043d\u044b\u0439 <abbr title=\"Command Line Interface\" type=\"abbr\">CLI<\/abbr>. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 API \u0440\u0435\u0448\u0438\u043b\u0438 \u0437\u0430\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Swagger.  <\/p>\n<h4>\u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u043e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u0445  <\/h4>\n<blockquote>\n<p><a href=\"https:\/\/nestjs.com\/\" rel=\"noopener noreferrer nofollow\"><strong>Nest (NestJS)<\/strong><\/a> \u2014 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 <a href=\"https:\/\/nodejs.org\/en\/\" rel=\"noopener noreferrer nofollow\">Node.js<\/a>. \u0414\u0430\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u044b\u0439 (\u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e <em>ECMAScript<\/em>) <em>JavaScript<\/em> \u0441 \u043f\u043e\u043b\u043d\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 <a href=\"https:\/\/www.typescriptlang.org\/\" rel=\"noopener noreferrer nofollow\">TypeScript<\/a> (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <em>TypeScript<\/em> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c) \u0438 \u0441\u043e\u0447\u0435\u0442\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e, \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c <em>Nest<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"https:\/\/expressjs.com\/ru\/\" rel=\"noopener noreferrer nofollow\">Express<\/a> (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e), \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/www.fastify.io\/\" rel=\"noopener noreferrer nofollow\">Fastify<\/a>.<\/p>\n<\/blockquote>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e Nest \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/663234\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<blockquote>\n<p><a href=\"https:\/\/swagger.io\/\" rel=\"noopener noreferrer nofollow\"><strong>Swagger<\/strong> <\/a>\u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c API. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0438 \u043c\u0430\u0448\u0438\u043d\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 <a href=\"https:\/\/highload.today\/rest-api-soap\/\" rel=\"noopener noreferrer nofollow\">REST API<\/a> \u0431\u0435\u0437 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043a\u043e\u0434\u0443. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Swagger \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0435\u0435 \u0434\u0440\u0443\u0433\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0438\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c.  <\/p>\n<\/blockquote>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e Swagger \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/highload.today\/swagger-api\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>\u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u043b \u0432\u044b\u0448\u0435, Nest.js \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043e\u0449\u043d\u044b\u0439 CLI. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u0443\u0431\u0435\u0434\u0438\u0432\u0448\u0438\u0441\u044c \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d <a href=\"https:\/\/nodejs.org\/en\/\" rel=\"noopener noreferrer nofollow\">Node.js<\/a> \u0438 <a href=\"https:\/\/www.npmjs.com\/\" rel=\"noopener noreferrer nofollow\">npm<\/a>. \u0414\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:  <\/p>\n<pre><code class=\"bash\">$ npm i -g @nestjs\/cli<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a CLI \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>rest-api-with-swagger<\/code>:<\/p>\n<pre><code class=\"bash\">$ nest new rest-api-with-swagger<\/code><\/pre>\n<p>\u0412 Nest.js \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 (<code>app.controller.ts<\/code>), \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"javascript\">import { Controller, Get } from '@nestjs\/common'; import { AppService } from '.\/app.service';  @Controller() export class AppController {   constructor(private readonly appService: AppService) {}    @Get()   getHello(): string {     return this.appService.getHello();   } } <\/code><\/pre>\n<p>\u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438:<\/p>\n<pre><code class=\"javascript\">import { Injectable } from '@nestjs\/common';  @Injectable() export class AppService {   getHello(): string {     return 'Hello World!';   } }<\/code><\/pre>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b (\u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u0439\u043f\u044b <em>(<\/em><a href=\"https:\/\/docs.nestjs.com\/pipes\" rel=\"noopener noreferrer nofollow\"><em>Pipes<\/em><\/a><em>)<\/em>, \u0433\u0430\u0440\u0434\u044b <em>(<\/em><a href=\"https:\/\/docs.nestjs.com\/guards\" rel=\"noopener noreferrer nofollow\"><em>Guards<\/em><\/a><em>)<\/em> \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438) \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043c\u043e\u0434\u0443\u043b\u0438 <em>(<\/em><a href=\"https:\/\/docs.nestjs.com\/modules\" rel=\"noopener noreferrer nofollow\"><em>Modules<\/em><\/a><em>)<\/em> &#8212; \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<h4>REST API<\/h4>\n<p>\u041f\u0443\u0441\u0442\u044c \u043d\u0430\u0448\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e API, \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043c\u0435\u0442\u043a\u0438 <em>(notes)<\/em>. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">$ nest g resource notes # \u0438\u043b\u0438 nest generate resource notes<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438, \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442 \u0435\u0433\u043e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code>src notes |-- dto    -- create-note.dto.ts -- update-note.dto.ts |-- entities   -- note.entity.ts -- notes.controller.spec.ts    -- notes.controller.ts   -- notes.service.spec.ts   -- notes.service.ts   -- notes.module.ts ...<\/code><\/pre>\n<p> \u041a\u043e\u0434 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">import {    Controller, Get, Post,    Body, Patch, Param, Delete, Query  } from '@nestjs\/common'; import { NotesService } from '.\/notes.service'; import { CreateNoteDto } from '.\/dto\/create-note.dto'; import { UpdateNoteDto } from '.\/dto\/update-note.dto';  \/\/ \u0412\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0432 \u043f\u0443\u0442\u0438 \/notes, \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u044d\u0442\u043e\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 @Controller('notes') export class NotesController {   constructor(private readonly notesService: NotesService) {}    @Post() \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 POST http:\/\/localhost\/notes?userId={userId}   create(   @Query('userId') userId: number, \/\/ &lt;--- \u0434\u043e\u0441\u0442\u0430\u043d\u0435\u0442 userId \u0438\u0437 query \u0441\u0442\u0440\u043e\u043a\u0438      @Body() createNoteDto: CreateNoteDto ) {     return this.notesService.create(userId, createNoteDto);   }    @Get() \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 GET http:\/\/localhost\/notes?userId={userId}   findAll(@Query('userId') userId: number) {     return this.notesService.findAll(userId);   }    @Get(':noteId') \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 GET http:\/\/localhost\/notes\/{noteId}   findOne(@Param('noteId') noteId: number) {     return this.notesService.findOne(noteId);   }    @Patch(':noteId') \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 PATCH http:\/\/localhost\/notes\/{noteId}   update(@Param('noteId') noteId: number, @Body() updateNoteDto: UpdateNoteDto) {     return this.notesService.update(noteId, updateNoteDto);   }    @Delete(':noteId') \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 DELETE http:\/\/localhost\/notes\/{noteId}   remove(@Param('noteId') noteId: number) {     return this.notesService.remove(noteId);   } }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0440\u0430\u0431\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0441\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f REST API. \u0414\u0430\u043b\u0435\u0435, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u0432 <code>NotesService<\/code>. \u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f, \u0437\u0430\u043c\u0435\u0442\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0437\u0430\u043c\u0435\u0442\u043e\u043a (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0411\u0414), \u043d\u043e \u044d\u0442\u043e \u0442\u0435\u043c\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/docs.nestjs.com\/techniques\/database\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>. <\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u0438 (<a href=\"https:\/\/github.com\/AlexeyGurtovenko\/rest-api-with-swagger\/blob\/main\/src\/notes\/dto\/create-note.dto.ts\" rel=\"noopener noreferrer nofollow\">CreateNoteDto<\/a>, <a href=\"https:\/\/github.com\/AlexeyGurtovenko\/rest-api-with-swagger\/blob\/main\/src\/notes\/dto\/update-note.dto.ts\" rel=\"noopener noreferrer nofollow\">UpdateNoteDto<\/a> \u0438 <a href=\"https:\/\/github.com\/AlexeyGurtovenko\/rest-api-with-swagger\/blob\/main\/src\/notes\/entities\/note.entity.ts\" rel=\"noopener noreferrer nofollow\">Note<\/a>), \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u0441\u0430\u043c\u0438 \u0437\u0430\u043c\u0435\u0442\u043a\u0438 \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0434 \u043d\u0438\u043c\u0438. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u043e\u0434 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">import { Injectable } from '@nestjs\/common'; import { CreateNoteDto } from '.\/dto\/create-note.dto'; import { UpdateNoteDto } from '.\/dto\/update-note.dto'; import { Note } from '.\/entities\/note.entity';  @Injectable() export class NotesService {    private _notes: Note[] = [];    create(userId: number, dto: CreateNoteDto) {     const id = this._getRandomInt();     const note = new Note(id, userId, dto.title, dto.content);     this._notes.push(note);     return note;   }    findAll(userId: number) {     return this._notes.filter(note => note.userId == userId);   }    findOne(noteId: number) {     return this._notes.filter(note => note.id == noteId);   }    update(noteId: number, dto: UpdateNoteDto) {     const index = this._notes.findIndex(note => note.id == noteId)          if (index === -1) {       return;     }      const { id, userId } = this._notes[index];     this._notes[index] = new Note(id, userId, dto.title, dto.content);     return this._notes[index];   }    remove(noteId: number) {     this._notes = this._notes.filter(note => note.id != noteId)   }    private _getRandomInt() {     return Math.floor(Math.random() * 100);   } }<\/code><\/pre>\n<p>\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0435 CRUD-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438 <s>(\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c)<\/s>, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e. \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e API. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c Swagger-\u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f Nest.js:<\/p>\n<pre><code class=\"bash\">$ npm install --save @nestjs\/swagger swagger-ui-express<\/code><\/pre>\n<p>\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0435\u0433\u043e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0432 \u0444\u0430\u0439\u043b\u0435 <code>main.ts<\/code>:<\/p>\n<pre><code class=\"javascript\">import { NestFactory } from '@nestjs\/core'; import { SwaggerModule, DocumentBuilder } from '@nestjs\/swagger'; import { AppModule } from '.\/app.module';  async function bootstrap() {   const app = await NestFactory.create(AppModule);    const config = new DocumentBuilder()     .setTitle('Notes API')     .setDescription('The notes API description')     .setVersion('1.0')     .build();        const document = SwaggerModule.createDocument(app, config);   SwaggerModule.setup('api', app, document);    await app.listen(3000); }  bootstrap();<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u0441\u044f \u0432 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">$ npm run start:dev<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/localhost:3000\/api\/\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:3000\/api\/<\/a> \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430:<\/p>\n<figure class=\"bordered full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/257\/a72\/c8f\/257a72c8fc86fc39478aaf80716a7c1b.png\" alt=\"\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u043e Swagger \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e API\" title=\"\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u043e Swagger \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e API\" width=\"1489\" height=\"901\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/257\/a72\/c8f\/257a72c8fc86fc39478aaf80716a7c1b.png\"\/><figcaption>\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u043e Swagger \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e API<\/figcaption><\/figure>\n<p>\u0423\u0436\u0435 \u0447\u0442\u043e-\u0442\u043e, \u043d\u043e \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0435\u0449\u0435 \u043d\u0435 \u043f\u043e\u0445\u043e\u0436\u0435. <\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e <code>Notes<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0441\u0438\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 <code>NotesController<\/code>:<\/p>\n<pre><code class=\"javascript\">@ApiTags('Notes')  \/\/ &lt;---- \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u043a\u0446\u0438\u044f \u0432 Swagger \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 @Controller('notes') export class NotesController {   ... }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0443\u0431\u0435\u0440\u0435\u043c \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u043c (<code>\/<\/code>), \u043f\u043e\u0432\u0435\u0441\u0438\u0432 \u043d\u0430 \u043d\u0435\u0433\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>ApiExcludeEndpoint<\/code>:<\/p>\n<pre><code class=\"javascript\">@Controller() export class AppController {   constructor(private readonly appService: AppService) {}    @Get()   @ApiExcludeEndpoint() \/\/ &lt;----- \u0421\u043a\u0440\u044b\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432 Swagger \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438   getHello(): string {     ...   } }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/754\/853\/1d4\/7548531d467b7c6af55346094be4da84.png\" width=\"1514\" height=\"851\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/754\/853\/1d4\/7548531d467b7c6af55346094be4da84.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0448\u0438\u043c \u044d\u043d\u0434\u043e\u0438\u043d\u0442\u0430\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0443\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"javascript\">@ApiTags('Notes') @Controller('notes')  export class NotesController {    ...    @Patch(':noteId') \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 PATCH http:\/\/localhost\/notes\/{noteId}   @ApiOperation({ summary: \"Updates a note with specified id\" })   @ApiParam({ name: \"noteId\", required: true, description: \"Note identifier\" })   @ApiResponse({ status: HttpStatus.OK, description: \"Success\", type: Note })   @ApiResponse({ status: HttpStatus.BAD_REQUEST, description: \"Bad Request\" })   update(     @Param('noteId', new ParseIntPipe()) noteId: number,      @Body() updateNoteDto: UpdateNoteDto ) {     return this.notesService.update(noteId, updateNoteDto);   }  ... }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u043e <a href=\"https:\/\/github.com\/AlexeyGurtovenko\/rest-api-with-swagger\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>. \u0421\u043f\u0438\u0441\u043e\u043a \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b API, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043f\u043e <a href=\"https:\/\/docs.nestjs.com\/openapi\/decorators\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u0434\u043b\u044f \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 <code>update<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0430\u0439\u043f <code>ParseIntPipe<\/code>, \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0441 \u043d\u0438\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u0439\u043f\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0441\u044f \u043f\u043e <a href=\"https:\/\/docs.nestjs.com\/pipes\" rel=\"noopener noreferrer nofollow\">\u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c Swagger \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0438 <code>dto<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043b\u0430\u0441\u0441 <code>Note<\/code>:<\/p>\n<pre><code class=\"javascript\">import { ApiProperty } from \"@nestjs\/swagger\";  export class Note {     @ApiProperty({ description: \"Note identifier\", nullable: false })     id: number;      @ApiProperty({ description: \"User identifier\", nullable: true })     userId: number;          @ApiProperty({ description: \"Note title\", nullable: true })     title: string;          @ApiProperty({ description: \"Note content\", nullable: true })     content: string;    ... }<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043d\u0430\u0448\u0435 Swagger \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d24\/4c1\/ddd\/d244c1ddd9149eba340b5b820142dd0e.png\" width=\"1467\" height=\"931\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d24\/4c1\/ddd\/d244c1ddd9149eba340b5b820142dd0e.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d8d\/cf4\/7c8\/d8dcf47c87b63c884bcea468bf7df633.png\" width=\"1461\" height=\"867\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d8d\/cf4\/7c8\/d8dcf47c87b63c884bcea468bf7df633.png\"\/><figcaption><\/figcaption><\/figure>\n<p>API \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u044b \u0433\u043e\u0442\u043e\u0432\u044b, \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0449\u0438\u0442\u0438\u043c \u043d\u0430\u0448 \u0440\u0435\u0441\u0443\u0440\u0441 \u043e\u0442 \u043d\u0435\u0441\u0430\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0422\u0417 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u043e\u0441\u043e\u0431 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e API \u043a\u043b\u044e\u0447\u0430 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/starkovden.github.io\/authentication-and-authorization.html\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>). \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c <a href=\"https:\/\/jwt.io\/\" rel=\"noopener noreferrer nofollow\">JWT<\/a> \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"https:\/\/docs.nestjs.com\/security\/authentication\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>, <a href=\"https:\/\/www.codemag.com\/Article\/2001081\/Nest.js-Step-by-Step-Part-3-Users-and-Authentication\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442 <\/a>\u0438\u043b\u0438 <a href=\"https:\/\/progressivecoder.com\/how-to-implement-nestjs-jwt-authentication-using-jwt-strategy\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>. <\/p>\n<p>\u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0431\u0443\u0434\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/www.passportjs.org\/\" rel=\"noopener noreferrer nofollow\">passport<\/a>, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u043e\u0434\u0443\u043b\u0435\u043c (\u043e\u0431\u0435\u0440\u0442\u043a\u043e\u0439) \u0434\u043b\u044f Nest.js &#8212; <a href=\"https:\/\/github.com\/nestjs\/passport\" rel=\"noopener noreferrer nofollow\">@nestjs\/passport<\/a>. \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c:<\/p>\n<pre><code class=\"bash\">$ npm install --save @nestjs\/passport passport passport-headerapikey<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e:<\/p>\n<pre><code class=\"bash\">$ nest g mo authorization # nest generate module authorization<\/code><\/pre>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 passport \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 <a href=\"https:\/\/www.passportjs.org\/packages\/\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/a>. \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043e\u0434\u043d\u0443 \u0438\u0437 \u043d\u0438\u0445 (<code>api-key.strategy.ts<\/code>):<\/p>\n<pre><code class=\"javascript\">import { Injectable, UnauthorizedException } from \"@nestjs\/common\"; import { ConfigService } from \"@nestjs\/config\"; import { PassportStrategy } from \"@nestjs\/passport\"; import Strategy from \"passport-headerapikey\";  @Injectable() export class ApiKeyStrategy extends PassportStrategy(Strategy, \"api-key\") {      constructor(private readonly _configService: ConfigService) {     super({ header: \"X-API-KEY\", prefix: \"\" },            true,            async (apiKey, done) => this.validate(apiKey, done)          );   }    public validate = (incomingApiKey: string, done: (error: Error, data) => Record&lt;string, unknown>) => {     const configApiKey = this._configService.get(\"apiKey\");      if (configApiKey === incomingApiKey) {       done(null, true);     }      done(new UnauthorizedException(), null);   }; }<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 <code>ApiKeyStrategy<\/code> \u0438\u043d\u0436\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441 <code>ConfigService<\/code>. \u0414\u0430\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043f\u0430\u043a\u0435\u0442\u0430 <a href=\"https:\/\/github.com\/nestjs\/config\" rel=\"noopener noreferrer nofollow\">@nestjs\/config<\/a> \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f (\u0442.\u0435. \u0444\u0430\u0439\u043b\u044b \u0432\u0438\u0434\u0430 <code>.env<\/code>). \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043a\u043b\u044e\u0447 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a API \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c \u0438 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0444\u0430\u0439\u043b\u0435 <code>.env<\/code> (\u0441\u043c. <a href=\"https:\/\/github.com\/AlexeyGurtovenko\/rest-api-with-swagger\/blob\/main\/.env.sample\" rel=\"noopener noreferrer nofollow\">\u043a\u043e\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/a>). \u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043c\u043e\u0434\u0443\u043b\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0441\u044f <a href=\"https:\/\/docs.nestjs.com\/techniques\/configuration#configuration\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u0432\u043e\u0435\u0434\u0438\u043d\u043e \u043d\u0430\u0448 \u043c\u043e\u0434\u0443\u043b\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 (<code>authorization.module.ts<\/code>):<\/p>\n<pre><code class=\"javascript\">import { Module } from \"@nestjs\/common\"; import { ConfigModule } from \"@nestjs\/config\"; import { PassportModule } from \"@nestjs\/passport\"; import { ApiKeyStrategy } from \".\/api-key.strategy\";  @Module({   imports: [PassportModule, ConfigModule],   providers: [ApiKeyStrategy], }) export class AuthorizationModule {}<\/code><\/pre>\n<p>\u041c\u043e\u0434\u0443\u043b\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0433\u043e\u0442\u043e\u0432, \u043d\u043e \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430\u0448\u0435\u0433\u043e <code>NotesController<\/code> \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 API \u043a\u043b\u044e\u0447\u0430 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0414\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b API \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440:<\/p>\n<pre><code class=\"javascript\">@ApiTags('Notes') @ApiSecurity(\"X-API-KEY\", [\"X-API-KEY\"]) \/\/ &lt;----- \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0447\u0435\u0440\u0435\u0437 Swagger  @Controller('notes') export class NotesController {   constructor(private readonly notesService: NotesService) {}    @Post() \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 POST http:\/\/localhost\/notes?userId={userId}   @UseGuards(AuthGuard(\"api-key\")) \/\/ &lt;---- \u0412\u0435\u0440\u043d\u0435\u0442 401 (unauthorized)    \/\/ \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0431\u0435\u0437 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0433\u043e API \u043a\u043b\u044e\u0447\u0430 ...   create(   @Query('userId', new ParseIntPipe()) userId: number,    @Body() createNoteDto: CreateNoteDto ) {     return this.notesService.create(userId, createNoteDto);   } }<\/code><\/pre>\n<p>\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b <code>main.ts<\/code>:<\/p>\n<pre><code class=\"javascript\">async function bootstrap() {   const app = await NestFactory.create(AppModule);    const config = new DocumentBuilder()     .setTitle('Notes API')     .setDescription('The notes API description')     .setVersion('1.0')     .addApiKey({       \/\/ &lt;--- \u041f\u043e\u043a\u0430\u0436\u0435\u0442 \u043e\u043f\u0446\u0438\u044e X-API-KEY (apiKey)       type: \"apiKey\",  \/\/ \u0432 \u043e\u043a\u043d\u0435 'Available authorizations' \u0432 Swagger       name: \"X-API-KEY\",        in: \"header\",        description: \"Enter your API key\"  }, \"X-API-KEY\")     .build();      ... }<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 Swagger \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e API \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5f9\/24d\/fe5\/5f924dfe5f23c36e33a58e9c5a403687.png\" width=\"1486\" height=\"788\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5f9\/24d\/fe5\/5f924dfe5f23c36e33a58e9c5a403687.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0442\u0430\u043a\u0436\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0437\u0430\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 <a href=\"https:\/\/github.com\/nestjs\/nest\/tree\/master\/sample\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043a\u043e\u0434\u0430<\/a> \u043e\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430.<\/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\/668340\/\"> https:\/\/habr.com\/ru\/post\/668340\/<\/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 article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0414\u0440\u0443\u0437\u044c\u044f, \u0432\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442!\u00a0<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043b\u0435\u043a\u0441\u0435\u0439 \u0438 \u0432\u043e\u0442 \u0443\u0436\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c frontend-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439. <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043e\u043f\u0438\u0448\u0443 \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e RESTfull API. \u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044f \u043f\u0438\u0441\u0430\u043b \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Typescript, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u043b\u043e \u0431\u044b \u043c\u043d\u0435 \u0436\u0438\u0437\u043d\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430\u0434 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u043d\u0430\u0434\u0435\u044e\u0441\u044c \u043c\u043e\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0438 \u0432\u0430\u043c!<\/p>\n<h3>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u0438  <\/h3>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0433\u0438\u043f\u043e\u0442\u0435\u0437 \u043f\u0440\u0438 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u0441\u0440\u043e\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u0440\u0430\u0431\u043e\u0447\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043c\u043d\u0435 \u0434\u043e\u0432\u0435\u043b\u043e\u0441\u044c \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0434 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u043e\u043c. \u042d\u0442\u043e \u0431\u044b\u043b\u043e backend-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0435 RESTfull API \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 Nest.js \u0438 Swagger.   <\/p>\n<h4>\u0412\u044b\u0431\u043e\u0440 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439 <\/h4>\n<p>\u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u0435 \u0441\u0442\u0435\u043a\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Node.js, \u0442\u0430\u043a \u043a\u0430\u043a \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 RESTfull API \u043b\u0435\u0433\u043b\u0430 \u043d\u0430 \u043f\u043b\u0435\u0447\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b frontend-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a Angular. <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 Nest.js \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442\u043e\u043c, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u0438 \u044d\u0442\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u044f\u043b\u0438\u0441\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c\u0438 \u0432 Angular. \u0417\u0434\u0435\u0441\u044c \u0438 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 \u043d\u0430\u043c Dependency Injection, RxJS, Typescript, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0438 \u043c\u043e\u0449\u043d\u044b\u0439 <abbr title=\"Command Line Interface\" type=\"abbr\">CLI<\/abbr>. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 API \u0440\u0435\u0448\u0438\u043b\u0438 \u0437\u0430\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Swagger.  <\/p>\n<h4>\u0412\u043a\u0440\u0430\u0442\u0446\u0435 \u043e \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044f\u0445  <\/h4>\n<blockquote>\n<p><a href=\"https:\/\/nestjs.com\/\" rel=\"noopener noreferrer nofollow\"><strong>Nest (NestJS)<\/strong><\/a> \u2014 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0430 <a href=\"https:\/\/nodejs.org\/en\/\" rel=\"noopener noreferrer nofollow\">Node.js<\/a>. \u0414\u0430\u043d\u043d\u044b\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u044b\u0439 (\u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e <em>ECMAScript<\/em>) <em>JavaScript<\/em> \u0441 \u043f\u043e\u043b\u043d\u043e\u0439 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 <a href=\"https:\/\/www.typescriptlang.org\/\" rel=\"noopener noreferrer nofollow\">TypeScript<\/a> (\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <em>TypeScript<\/em> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c) \u0438 \u0441\u043e\u0447\u0435\u0442\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e, \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u041f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c <em>Nest<\/em> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"https:\/\/expressjs.com\/ru\/\" rel=\"noopener noreferrer nofollow\">Express<\/a> (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e), \u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <a href=\"https:\/\/www.fastify.io\/\" rel=\"noopener noreferrer nofollow\">Fastify<\/a>.<\/p>\n<\/blockquote>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e Nest \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/663234\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<blockquote>\n<p><a href=\"https:\/\/swagger.io\/\" rel=\"noopener noreferrer nofollow\"><strong>Swagger<\/strong> <\/a>\u2014 \u044d\u0442\u043e \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c API. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0435\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0438 \u043c\u0430\u0448\u0438\u043d\u044b \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 <a href=\"https:\/\/highload.today\/rest-api-soap\/\" rel=\"noopener noreferrer nofollow\">REST API<\/a> \u0431\u0435\u0437 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043a\u043e\u0434\u0443. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Swagger \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0435\u0435 \u0434\u0440\u0443\u0433\u0438\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0438\u043b\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c.  <\/p>\n<\/blockquote>\n<p>\u0411\u043e\u043b\u0435\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e Swagger \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/highload.today\/swagger-api\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h2>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>\u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u043e\u0442\u043c\u0435\u0442\u0438\u043b \u0432\u044b\u0448\u0435, Nest.js \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0442\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043e\u0449\u043d\u044b\u0439 CLI. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0435\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438, \u0443\u0431\u0435\u0434\u0438\u0432\u0448\u0438\u0441\u044c \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d <a href=\"https:\/\/nodejs.org\/en\/\" rel=\"noopener noreferrer nofollow\">Node.js<\/a> \u0438 <a href=\"https:\/\/www.npmjs.com\/\" rel=\"noopener noreferrer nofollow\">npm<\/a>. \u0414\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443:  <\/p>\n<pre><code class=\"bash\">$ npm i -g @nestjs\/cli<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a CLI \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>rest-api-with-swagger<\/code>:<\/p>\n<pre><code class=\"bash\">$ nest new rest-api-with-swagger<\/code><\/pre>\n<p>\u0412 Nest.js \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u0437\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u043e\u0432, \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u043c\u0438. \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u0438\u0437 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 (<code>app.controller.ts<\/code>), \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043f\u0440\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"javascript\">import { Controller, Get } from '@nestjs\/common'; import { AppService } from '.\/app.service';  @Controller() export class AppController {   constructor(private readonly appService: AppService) {}    @Get()   getHello(): string {     return this.appService.getHello();   } } <\/code><\/pre>\n<p>\u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438:<\/p>\n<pre><code class=\"javascript\">import { Injectable } from '@nestjs\/common';  @Injectable() export class AppService {   getHello(): string {     return 'Hello World!';   } }<\/code><\/pre>\n<p>\u0421\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b (\u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u0439\u043f\u044b <em>(<\/em><a href=\"https:\/\/docs.nestjs.com\/pipes\" rel=\"noopener noreferrer nofollow\"><em>Pipes<\/em><\/a><em>)<\/em>, \u0433\u0430\u0440\u0434\u044b <em>(<\/em><a href=\"https:\/\/docs.nestjs.com\/guards\" rel=\"noopener noreferrer nofollow\"><em>Guards<\/em><\/a><em>)<\/em> \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438) \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043c\u043e\u0434\u0443\u043b\u0438 <em>(<\/em><a href=\"https:\/\/docs.nestjs.com\/modules\" rel=\"noopener noreferrer nofollow\"><em>Modules<\/em><\/a><em>)<\/em> &#8212; \u0441\u0442\u0440\u043e\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<h4>REST API<\/h4>\n<p>\u041f\u0443\u0441\u0442\u044c \u043d\u0430\u0448\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e API, \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043c\u0435\u0442\u043a\u0438 <em>(notes)<\/em>. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">$ nest g resource notes # \u0438\u043b\u0438 nest generate resource notes<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438, \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442 \u0435\u0433\u043e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code>src notes |-- dto    -- create-note.dto.ts -- update-note.dto.ts |-- entities   -- note.entity.ts -- notes.controller.spec.ts    -- notes.controller.ts   -- notes.service.spec.ts   -- notes.service.ts   -- notes.module.ts ...<\/code><\/pre>\n<p> \u041a\u043e\u0434 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043d\u0430\u0434 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">import {    Controller, Get, Post,    Body, Patch, Param, Delete, Query  } from '@nestjs\/common'; import { NotesService } from '.\/notes.service'; import { CreateNoteDto } from '.\/dto\/create-note.dto'; import { UpdateNoteDto } from '.\/dto\/update-note.dto';  \/\/ \u0412\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0432 \u043f\u0443\u0442\u0438 \/notes, \u0431\u0443\u0434\u0443\u0442 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u044d\u0442\u043e\u0442 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 @Controller('notes') export class NotesController {   constructor(private readonly notesService: NotesService) {}    @Post() \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 POST http:\/\/localhost\/notes?userId={userId}   create(   @Query('userId') userId: number, \/\/ &lt;--- \u0434\u043e\u0441\u0442\u0430\u043d\u0435\u0442 userId \u0438\u0437 query \u0441\u0442\u0440\u043e\u043a\u0438      @Body() createNoteDto: CreateNoteDto ) {     return this.notesService.create(userId, createNoteDto);   }    @Get() \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 GET http:\/\/localhost\/notes?userId={userId}   findAll(@Query('userId') userId: number) {     return this.notesService.findAll(userId);   }    @Get(':noteId') \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 GET http:\/\/localhost\/notes\/{noteId}   findOne(@Param('noteId') noteId: number) {     return this.notesService.findOne(noteId);   }    @Patch(':noteId') \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 PATCH http:\/\/localhost\/notes\/{noteId}   update(@Param('noteId') noteId: number, @Body() updateNoteDto: UpdateNoteDto) {     return this.notesService.update(noteId, updateNoteDto);   }    @Delete(':noteId') \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 DELETE http:\/\/localhost\/notes\/{noteId}   remove(@Param('noteId') noteId: number) {     return this.notesService.remove(noteId);   } }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0440\u0430\u0431\u043e\u0442\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0441\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f REST API. \u0414\u0430\u043b\u0435\u0435, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u0432 <code>NotesService<\/code>. \u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f, \u0437\u0430\u043c\u0435\u0442\u043a\u0438 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c \u0437\u0430\u043c\u0435\u0442\u043e\u043a (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0411\u0414), \u043d\u043e \u044d\u0442\u043e \u0442\u0435\u043c\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/docs.nestjs.com\/techniques\/database\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>. <\/p>\n<p>\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u0438 (<a href=\"https:\/\/github.com\/AlexeyGurtovenko\/rest-api-with-swagger\/blob\/main\/src\/notes\/dto\/create-note.dto.ts\" rel=\"noopener noreferrer nofollow\">CreateNoteDto<\/a>, <a href=\"https:\/\/github.com\/AlexeyGurtovenko\/rest-api-with-swagger\/blob\/main\/src\/notes\/dto\/update-note.dto.ts\" rel=\"noopener noreferrer nofollow\">UpdateNoteDto<\/a> \u0438 <a href=\"https:\/\/github.com\/AlexeyGurtovenko\/rest-api-with-swagger\/blob\/main\/src\/notes\/entities\/note.entity.ts\" rel=\"noopener noreferrer nofollow\">Note<\/a>), \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u0441\u0430\u043c\u0438 \u0437\u0430\u043c\u0435\u0442\u043a\u0438 \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0434 \u043d\u0438\u043c\u0438. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043a\u043e\u0434 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">import { Injectable } from '@nestjs\/common'; import { CreateNoteDto } from '.\/dto\/create-note.dto'; import { UpdateNoteDto } from '.\/dto\/update-note.dto'; import { Note } from '.\/entities\/note.entity';  @Injectable() export class NotesService {    private _notes: Note[] = [];    create(userId: number, dto: CreateNoteDto) {     const id = this._getRandomInt();     const note = new Note(id, userId, dto.title, dto.content);     this._notes.push(note);     return note;   }    findAll(userId: number) {     return this._notes.filter(note => note.userId == userId);   }    findOne(noteId: number) {     return this._notes.filter(note => note.id == noteId);   }    update(noteId: number, dto: UpdateNoteDto) {     const index = this._notes.findIndex(note => note.id == noteId)          if (index === -1) {       return;     }      const { id, userId } = this._notes[index];     this._notes[index] = new Note(id, userId, dto.title, dto.content);     return this._notes[index];   }    remove(noteId: number) {     this._notes = this._notes.filter(note => note.id != noteId)   }    private _getRandomInt() {     return Math.floor(Math.random() * 100);   } }<\/code><\/pre>\n<p>\u0411\u0430\u0437\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0435\u0435 CRUD-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438 <s>(\u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c)<\/s>, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e. \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e API. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c Swagger-\u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f Nest.js:<\/p>\n<pre><code class=\"bash\">$ npm install --save @nestjs\/swagger swagger-ui-express<\/code><\/pre>\n<p>\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u0435\u0433\u043e \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0432 \u0444\u0430\u0439\u043b\u0435 <code>main.ts<\/code>:<\/p>\n<pre><code class=\"javascript\">import { NestFactory } from '@nestjs\/core'; import { SwaggerModule, DocumentBuilder } from '@nestjs\/swagger'; import { AppModule } from '.\/app.module';  async function bootstrap() {   const app = await NestFactory.create(AppModule);    const config = new DocumentBuilder()     .setTitle('Notes API')     .setDescription('The notes API description')     .setVersion('1.0')     .build();        const document = SwaggerModule.createDocument(app, config);   SwaggerModule.setup('api', app, document);    await app.listen(3000); }  bootstrap();<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u0441\u044f \u0432 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">$ npm run start:dev<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430, \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/localhost:3000\/api\/\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:3000\/api\/<\/a> \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430:<\/p>\n<figure class=\"bordered full-width\"><figcaption>\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u043e Swagger \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e API<\/figcaption><\/figure>\n<p>\u0423\u0436\u0435 \u0447\u0442\u043e-\u0442\u043e, \u043d\u043e \u043d\u0430 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0435\u0449\u0435 \u043d\u0435 \u043f\u043e\u0445\u043e\u0436\u0435. <\/p>\n<p>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0435\u043c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0437\u0430\u043c\u0435\u0442\u043a\u0430\u043c\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e <code>Notes<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0441\u0438\u043c \u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e\u0439 \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 \u043d\u0430 <code>NotesController<\/code>:<\/p>\n<pre><code class=\"javascript\">@ApiTags('Notes')  \/\/ &lt;---- \u041e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0435\u043a\u0446\u0438\u044f \u0432 Swagger \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 @Controller('notes') export class NotesController {   ... }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435, \u0443\u0431\u0435\u0440\u0435\u043c \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043c\u0435\u0442\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u043c (<code>\/<\/code>), \u043f\u043e\u0432\u0435\u0441\u0438\u0432 \u043d\u0430 \u043d\u0435\u0433\u043e \u0434\u0435\u043a\u043e\u0440\u0430\u0442\u043e\u0440 <code>ApiExcludeEndpoint<\/code>:<\/p>\n<pre><code class=\"javascript\">@Controller() export class AppController {   constructor(private readonly appService: AppService) {}    @Get()   @ApiExcludeEndpoint() \/\/ &lt;----- \u0421\u043a\u0440\u044b\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0432 Swagger \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438   getHello(): string {     ...   } }<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0448\u0438\u043c \u044d\u043d\u0434\u043e\u0438\u043d\u0442\u0430\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c\u044b\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0443\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"javascript\">@ApiTags('Notes') @Controller('notes')  export class NotesController {    ...    @Patch(':noteId') \/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 PATCH http:\/\/localhost\/notes\/{noteId}   @ApiOperation({ summary: \"Updates a note with specified id\" })   @ApiParam({ name: \"noteId\", required: true, description: \"Note identifier\" })   @ApiResponse({ status: HttpStatus.OK, description: \"Success\", type: Note })   @ApiResponse({ status: HttpStatus.BAD_REQUEST, description: \"Bad Request\" })   update(     @Param('noteId', new ParseIntPipe()) noteId: number,      <\/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-333766","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333766","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=333766"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333766\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}