{"id":480675,"date":"2026-05-22T13:37:03","date_gmt":"2026-05-22T13:37:03","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=480675"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=480675","title":{"rendered":"Feature Based Clean Architecture. \u0427\u0430\u0441\u0442\u044c 1: \u042d\u0432\u043e\u043b\u044e\u0446\u0438\u044f NestJS-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u043d\u0435\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<blockquote>\n<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u0430\u044f \u0434\u043e\u043a\u0442\u0440\u0438\u043d\u0430 \u0434\u043b\u044f NestJS-\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432: \u0440\u0430\u0437\u0431\u043e\u0440 \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0434\u0435\u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0435\u0451 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438 \u0440\u043e\u0441\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430.<\/p>\n<\/blockquote>\n<p>\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u2014 \u0440\u0430\u0437\u0431\u043e\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0431\u044d\u043a\u0435\u043d\u0434 \u043d\u0430 NestJS \u0434\u0435\u0433\u0440\u0430\u0434\u0438\u0440\u0443\u0435\u0442 \u0441 \u0440\u043e\u0441\u0442\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0438 \u043a\u0430\u043a \u0438\u0434\u0435\u0438 Clean Architecture \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c. \u042f \u043f\u0440\u043e\u0439\u0434\u0443 \u043f\u043e \u043f\u043e\u043b\u043d\u043e\u043c\u0443 \u0446\u0438\u043a\u043b\u0443: \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u00ab\u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435\u00bb, \u043a\u0430\u043a feature-based-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u044e\u0442 \u043a\u0430\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442, \u0442\u0435\u0440\u044f\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0441\u0442\u044c \u0441 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u043e\u043c; \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0434\u0435\u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438; \u043e\u0446\u0435\u043d\u044e \u0432 \u0434\u0435\u043d\u044c\u0433\u0430\u0445 \u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e-\u0447\u0430\u0441\u0430\u0445, \u0432\u043e \u0447\u0442\u043e \u043e\u043d\u0438 \u043e\u0431\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0431\u0438\u0437\u043d\u0435\u0441\u0443; \u043e\u0431\u044a\u044f\u0441\u043d\u044e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u043a\u043e\u0434\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u0440\u043e\u0431\u0438\u0442\u044c \u043c\u043e\u043d\u043e\u043b\u0438\u0442 \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0437\u0430\u0434\u043e\u043b\u0433\u043e \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u044f \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0443 \u043f\u043e\u0434\u0445\u043e\u0434, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u0438\u0432 \u0434\u0435\u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438, \u2014 \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435. \u041a \u043a\u043e\u043d\u0446\u0443 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0441\u0432\u043e\u0438\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043a\u0432\u043e\u0437\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e\u0442 \u043d\u0430 System Design-\u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u0438\u0437 \u0440\u0430\u0437\u0430 \u0432 \u0440\u0430\u0437: \u0431\u044d\u043a\u0435\u043d\u0434 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Twitter. \u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d \u2014 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0412\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0448\u0430\u0440\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u0441\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0435\u043c \u0437\u0430 \u0441\u043a\u043e\u0431\u043a\u0438: \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u0434\u0430, \u0430 \u043d\u0435 \u043f\u0440\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0443\u044e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c. \u0421\u0442\u0435\u043a \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u2014 Node.js \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a NestJS. \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<ol>\n<li>\n<p>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0432\u0438\u0442\u0430<\/p>\n<\/li>\n<li>\n<p>\u041b\u0435\u043d\u0442\u0430 (feed)<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 (follow \/ unfollow)<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0444\u0438\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/p>\n<\/li>\n<li>\n<p>\u041b\u0430\u0439\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u0420\u0435\u0442\u0432\u0438\u0442\u044b<\/p>\n<\/li>\n<li>\n<p>\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 (replies)<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0438\u0441\u043a (\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0442\u0432\u0438\u0442\u043e\u0432, \u0445\u044d\u0448\u0442\u0435\u0433\u043e\u0432)<\/p>\n<\/li>\n<li>\n<p>\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f (\u043b\u0430\u0439\u043a\u0438, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u043e\u0442\u0432\u0435\u0442\u044b)<\/p>\n<\/li>\n<li>\n<p>\u041c\u0435\u0434\u0438\u0430 (\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \/ \u0432\u0438\u0434\u0435\u043e)<\/p>\n<\/li>\n<\/ol>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 Twitter \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0438 \u0441\u0442\u0440\u043e\u0438\u043b\u0441\u044f \u0433\u043e\u0434\u0430\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432 \u0441\u043e\u0442\u043d\u0438 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u0432 \u2014 \u043d\u043e \u0446\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442, \u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u0443\u044e \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044e \u043d\u0430 \u0437\u043d\u0430\u043a\u043e\u043c\u043e\u0439 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438. \u0421\u043f\u0438\u0441\u043e\u043a \u0444\u0438\u0447 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d, \u0441\u0445\u0435\u043c\u0430 \u0431\u0430\u0437\u044b \u0438 \u043d\u0430\u0431\u043e\u0440 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u043e\u0432 \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0435\u0437 \u0440\u0430\u0437\u0434\u0443\u043c\u0438\u0439, \u0441\u0442\u0435\u043a \u0432\u044b\u0431\u0440\u0430\u043d. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e NestJS \u2014 \u0438 \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u0436\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0430\u043c \u043e\u043f\u043e\u0440\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"bash\">src\/\u251c\u2500\u2500 main.ts\u251c\u2500\u2500 app.module.ts\u2502\u251c\u2500\u2500 modules\/\u2502   \u251c\u2500\u2500 auth\/\u2502   \u251c\u2500\u2500 users\/\u2502   \u251c\u2500\u2500 tweets\/\u2502   \u251c\u2500\u2500 feed\/\u2502   \u251c\u2500\u2500 likes\/\u2502   \u251c\u2500\u2500 comments\/\u2502   \u251c\u2500\u2500 retweets\/\u2502   \u251c\u2500\u2500 follows\/\u2502   \u251c\u2500\u2500 notifications\/\u2502   \u251c\u2500\u2500 search\/\u2502   \u2514\u2500\u2500 media\/\u2502\u251c\u2500\u2500 common\/\u2502   \u251c\u2500\u2500 guards\/\u2502   \u251c\u2500\u2500 interceptors\/\u2502   \u251c\u2500\u2500 filters\/\u2502   \u251c\u2500\u2500 decorators\/\u2502   \u2514\u2500\u2500 utils\/\u2502\u251c\u2500\u2500 database\/\u2502   \u251c\u2500\u2500 prisma\/ \u0438\u043b\u0438 typeorm\/\u2502   \u2514\u2500\u2500 migrations\/\u2502\u251c\u2500\u2500 config\/\u2502   \u2514\u2500\u2500 configuration.ts<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043e\u0441\u0442\u0430\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u2014 \u043a\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c. \u042d\u0442\u0430 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430 \u0434\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0441 \u0440\u0430\u0437\u043d\u043e\u0439 \u043f\u0440\u0438\u0440\u043e\u0434\u043e\u0439: \u0438 auth, \u0438 tweets, \u0438 search \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u0442\u043e\u043c\u0443 \u0436\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0443. \u041f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0434\u0443\u043b\u044f tweets:<\/p>\n<pre><code class=\"bash\">src\/modules\/tweets\/\u251c\u2500\u2500 tweets.module.ts\u251c\u2500\u2500 tweets.controller.ts\u251c\u2500\u2500 tweets.service.ts\u251c\u2500\u2500 dto\/\u2502   \u2514\u2500\u2500 create-tweet.dto.ts\u251c\u2500\u2500 entities\/\u2502   \u2514\u2500\u2500 tweet.entity.ts<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0441\u0445\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e: \u044f\u0441\u043d\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f, \u043d\u0438\u0437\u043a\u0438\u0439 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0436\u0435 \u2014 \u0431\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e\u0439 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u044b \u2014 \u043e\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u0433\u043e\u0434\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0440\u0443\u0434\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u043a\u043e\u0434. \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e: \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c, \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043c\u043e\u0434\u0443\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0441\u0442\u044c \u043f\u043e\u0447\u0442\u0438 \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435 \u2014 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f.<\/p>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b: \u0434\u0432\u0435 \u0440\u0443\u0447\u043a\u0438 \u2014 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0438 \u0432\u0445\u043e\u0434.<\/p>\n<pre><code class=\"typescript\">@Controller(\"auth\")export class AuthController {  constructor(private readonly authService: AuthService) {}  @Post(\"sign-up\")  async signUp(@Body() dto: SignUpDto): Promise&lt;SignUpResponse&gt; {    return this.authService.signUp(dto.email, dto.password);  }  @Post(\"sign-in\")  async signIn(@Body() dto: SignInDto): Promise&lt;SignInResponse&gt; {    return this.authService.signIn(dto.email, dto.password);  }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 ORM \u043f\u043e \u0445\u043e\u0434\u0443 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c TypeORM \u2014 \u0432\u044b\u0431\u043e\u0440 \u043d\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430 \u043e\u0431 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435, \u0438 \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0438\u0436\u0435, \u043b\u0435\u0433\u043a\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043d\u0430 Prisma, MikroORM \u0438\u043b\u0438 Drizzle. \u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u0435\u043d \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0438\u0448\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<pre><code class=\"typescript\">@Entity(\"users\")export class User {  @PrimaryGeneratedColumn(\"uuid\")  id: string;  @Column({ unique: true })  email: string;  @Column()  password: string;  @CreateDateColumn()  createdAt: Date;}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435, \u043a\u043e\u0434, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0439\u0441\u044f \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u0434\u043e\u043b\u0436\u0435\u043d \u0436\u0438\u0442\u044c \u0432 src\/modules\/users. \u0417\u043d\u0430\u0447\u0438\u0442, \u0438 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e. \u042d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435\u043f\u043b\u043e\u0445\u0430\u044f \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u0430 \u2014 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u044f\u043c\u043e \u0432 AuthService. \u041d\u043e \u0432 \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430: \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 AuthService \u0438\u043b\u0438 \u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 UsersService. \u041d\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0435 \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0438 \u043e\u0431\u0430 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0440\u0435\u0432\u044c\u044e \u2014 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0445 \u0440\u044f\u0434\u043e\u043c.<\/p>\n<pre><code class=\"typescript\">@Injectable()export class AuthService {  constructor(    @InjectRepository(User)    private readonly usersRepository: Repository&lt;User&gt;,  ) {}  async signUp(email: string, password: string) {    const existing = await this.usersRepository.findOne({      where: { email },    });    if (existing) {      throw new Error(\"User already exists\");    }    const user = this.usersRepository.create({      email,      password,    });    await this.usersRepository.save(user);    return {      id: user.id,      email: user.email,    };  }  async signIn(email: string, password: string) {    const user = await this.usersRepository.findOne({      where: { email },    });    if (!user) {      throw new UnauthorizedException(\"Invalid credentials\");    }    if (user.password !== password) {      throw new UnauthorizedException(\"Invalid credentials\");    }    return {      id: user.id,      email: user.email,    };  }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h4>\u041e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441<\/h4>\n<pre><code class=\"typescript\">import { Injectable, UnauthorizedException } from \"@nestjs\/common\";import { UsersService } from \"..\/users\/users.service\";@Injectable()export class AuthService {  constructor(private readonly usersService: UsersService) {}  async signUp(email: string, password: string) {    const existing = await this.usersService.findByEmail(email);    if (existing) {      throw new Error(\"User already exists\");    }    const user = await this.usersService.create({      email,      password,    });    return {      id: user.id,      email: user.email,    };  }  async signIn(email: string, password: string) {    const user = await this.usersService.findByEmail(email);    if (!user) {      throw new UnauthorizedException(\"Invalid credentials\");    }    if (user.password !== password) {      throw new UnauthorizedException(\"Invalid credentials\");    }    return {      id: user.id,      email: user.email,    };  }}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0435 \u043e\u0431\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0440\u0430\u0432\u043d\u043e\u043f\u0440\u0430\u0432\u043d\u044b\u043c\u0438, \u0438 \u0432 \u044d\u0442\u043e\u043c \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u043b\u043e\u0432\u0443\u0448\u043a\u0430: \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u0442\u0435\u043c, \u043a\u0430\u043a \u043a\u043e\u0434 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0441\u044f \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u0430 \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0441 \u043d\u0438\u043c \u0447\u0435\u0440\u0435\u0437 \u0433\u043e\u0434. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u043c\u043e\u0442\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u0432\u043f\u0435\u0440\u0451\u0434 \u2014 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0448\u043b\u043e \u043e\u043a\u043e\u043b\u043e \u0433\u043e\u0434\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u043d\u0430\u0448\u0451\u043b \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441\u0442\u0430\u043b\u043e \u043c\u043d\u043e\u0433\u043e, \u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438 \u043f\u0440\u0438\u0448\u043b\u0438 \u0438 \u0442\u0435, \u043a\u0442\u043e \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0430\u0431\u044c\u044e\u0437\u0438\u0442\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e. \u041c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0438 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c A\/B-\u0442\u0435\u0441\u0442\u044b \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0445. \u041f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0440\u0435\u0444\u0435\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441 \u0431\u043e\u043d\u0443\u0441\u0430\u043c\u0438 \u0438 \u043b\u0438\u043c\u0438\u0442\u0430\u043c\u0438. \u041c\u043e\u0434\u0443\u043b\u044c <code>users<\/code> \u043e\u0431\u0440\u043e\u0441 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0430\u043c\u0438 \u0438 \u043d\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u2014 \u0441\u043b\u043e\u0432\u043e\u043c, \u0432\u0441\u0451 \u0442\u043e, \u0447\u0442\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u043e\u0432\u043d\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442\u044c \u0434\u0435\u043d\u044c\u0433\u0438.<\/p>\n<p>\u0417\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e, \u043a \u043a\u0430\u043a\u043e\u043c\u0443 \u0441\u043f\u0438\u0441\u043a\u0443 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043d\u0443\u0436\u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <code>AuthService<\/code>:<\/p>\n<ol>\n<li>\n<p>\u0420\u0435\u0444\u0435\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438: \u043b\u0438\u043c\u0438\u0442\u044b \u043d\u0430 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f, \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 self-referral, \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0439 \u0442\u043e\u0433\u043e \u0436\u0435 email<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u043b\u043e\u0436\u043d\u0438\u0432\u0448\u0430\u044f\u0441\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441 \u0430\u043d\u0442\u0438-\u0430\u0431\u044c\u044e\u0437-\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 \u2014 \u043f\u043e IP, \u043f\u043e <code>deviceId<\/code>, \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0441 \u0442\u043e\u0433\u043e \u0436\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0441\u0448\u0438\u0440\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c <code>users<\/code> \u2014 \u043d\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f (\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0442\u0440\u0430\u0444\u0438\u043a\u0430, <code>deviceId<\/code>, \u0444\u043b\u0430\u0433\u0438 \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438), \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u044b, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u0430 \u2014 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0439, A\/B-\u0442\u0435\u0441\u0442\u044b, \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0442\u0440\u0430\u0444\u0438\u043a\u0430, \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/p>\n<\/li>\n<\/ol>\n<blockquote>\n<p><strong>\u041e\u0433\u043e\u0432\u043e\u0440\u043a\u0430 \u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u0445.<\/strong> \u0412 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u0449\u0438\u0442\u044b \u043e\u0442 \u0433\u043e\u043d\u043e\u043a \u0438 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0438. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0443\u0449\u0435\u043d\u043e \u2014 \u0440\u0435\u0447\u044c \u043e \u0434\u0435\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0430 \u043d\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0441\u0442\u0438. \u0418 \u0441\u0440\u0430\u0437\u0443 \u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043b\u043e\u0432\u0438\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u0451 \u044d\u0442\u043e \u043e\u0434\u043d\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439\u00bb \u2014 \u0442\u043e\u0436\u0435 \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 default. \u0414\u043b\u0438\u043d\u043d\u044b\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u0441 \u043f\u043e\u0445\u043e\u0434\u043e\u043c \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u044e\u044e \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443, \u0431\u043e\u043d\u0443\u0441\u0430\u043c\u0438 \u0438 \u043f\u0435\u0440\u0435\u0441\u0447\u0451\u0442\u043e\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u043c\u0438 \u0438 \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0440\u043e\u043d\u044f\u0435\u0442 \u0431\u0430\u0437\u0443. \u041a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0430 \u2014 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0432\u044b\u0445\u043e\u0434\u044f\u0449\u0430\u044f \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<\/blockquote>\n<h4>AuthService.signUp V2<\/h4>\n<pre><code class=\"typescript\">async signUp(  email: string,  password: string,  referralCode?: string,  adSourceCode?: string,  ip?: string,  deviceId?: string,): Promise&lt;SignUpResponse&gt; {  const existingUserByEmail = await this.usersRepository.findOne({    where: { email },  });  if (existingUserByEmail) {    throw new BadRequestException(\"User already exists\");  }  const registrationsFromIp = await this.usersRepository.count({    where: { registrationIp: ip },  });  if (registrationsFromIp &gt; 5) {    throw new BadRequestException(\"Too many registrations from this IP\");  }  const existingUserByDevice = await this.usersRepository.findOne({    where: { deviceId },  });  if (existingUserByDevice) {    throw new BadRequestException(\"Device already used\");  }  const adSource = adSourceCode    ? await this.adSourceRepository.findOne({ where: { code: adSourceCode } })    : null;  if (adSourceCode &amp;&amp; !adSource) {    throw new BadRequestException(\"Invalid ad source\");  }  if (adSource) {    const experimentGroup = Math.random() &gt; 0.5 ? \"A\" : \"B\";    await this.adSourceRepository.increment(      { id: adSource.id },      \"registrationsCount\",      1,    );    await this.analyticsRepository.save({      type: \"experiment_assignment\",      group: experimentGroup,      source: adSource.code,    });  }  const referral = referralCode    ? await this.referralsRepository.findOne({        where: { code: referralCode },        relations: [\"owner\"],      })    : null;  if (referralCode &amp;&amp; !referral) {    throw new BadRequestException(\"Invalid referral code\");  }  const referredByUser = referral?.owner ?? null;  if (referredByUser) {    const referralsByOwnerCount = await this.referralsRepository.count({      where: { owner: { id: referredByUser.id } },    });    if (referralsByOwnerCount &gt; 10) {      throw new BadRequestException(\"Referral limit exceeded\");    }    const existingReferralForEmail = await this.referralsRepository.findOne({      where: {        owner: { id: referredByUser.id },        invitedUser: { email },      },      relations: [\"invitedUser\"],    });    if (existingReferralForEmail) {      throw new BadRequestException(\"Referral abuse detected\");    }    if (referredByUser.email === email) {      throw new BadRequestException(\"Self-referral not allowed\");    }  }  const newUser = this.usersRepository.create({    email,    password,    adSource,    registrationIp: ip,    deviceId,    isVerified: false,  });  await this.usersRepository.save(newUser);  if (referredByUser) {    await this.bonusRepository.save({      userId: referredByUser.id,      amount: 100,      type: \"referral_reward\",    });    const parentReferral = await this.referralsRepository.findOne({      where: { invitedUser: { id: referredByUser.id } },      relations: [\"owner\"],    });    if (parentReferral) {      await this.bonusRepository.save({        userId: parentReferral.owner.id,        amount: 50,        type: \"second_level_referral\",      });    }    await this.referralsRepository.save({      owner: referredByUser,      invitedUser: newUser,    });  }  await this.analyticsRepository.save({    type: \"user_registered\",    userId: newUser.id,    source: adSource?.code,    ip,  });  return {    id: newUser.id,    email: newUser.email,  };}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043a \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0441\u043a\u0430\u0436\u0435\u0442: \u00ab\u041d\u0443 \u0438 \u0447\u0442\u043e? \u0412\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439 \u043f\u043e\u043a\u0440\u044b\u0442 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 \u0447\u0435\u0441\u0442\u043d\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430\u00bb. \u0418 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u044d\u0442\u043e \u043f\u0440\u0430\u0432\u0434\u0430. \u041d\u043e \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c\u0441\u044f \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043b\u0435\u0436\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 signUp, \u043a\u0430\u0440\u0442\u0438\u043d\u0430 \u0434\u0440\u0443\u0433\u0430\u044f: \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0435\u0439, \u0430\u043d\u0442\u0438-\u0444\u0440\u043e\u0434-\u043b\u043e\u0433\u0438\u043a\u043e\u0439, \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u043e\u0432\u044b\u043c\u0438 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043c\u0438, \u0440\u0435\u0444\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u043e\u0439 \u0438 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0439. \u041e\u043d\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043f\u044f\u0442\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432 \u0438 \u043e\u0442 \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0434\u043e\u043c\u0435\u043d\u043e\u0432 \u0431\u0438\u0437\u043d\u0435\u0441\u0430. \u0418 \u0432\u043e\u0442 \u044d\u0442\u043e \u2014 \u0430 \u043d\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u2014 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u0427\u0435\u0440\u0435\u0437 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0439 \u043a\u0432\u0430\u0440\u0442\u0430\u043b \u043b\u044e\u0431\u0430\u044f \u043d\u043e\u0432\u0430\u044f \u0444\u0438\u0447\u0430 \u2014 \u0430\u043d\u0442\u0438\u0431\u043e\u0442, \u0433\u0435\u043e-\u0442\u0430\u0440\u0433\u0435\u0442\u0438\u043d\u0433, \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f email \u2014 \u0431\u0443\u0434\u0435\u0442 \u0448\u0438\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e \u0436\u0435 \u043c\u0435\u0441\u0442\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u00ab\u0432\u0441\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0436\u0438\u0432\u0443\u0442 \u0432 signUp\u00bb.<\/p>\n<p>V2 \u043f\u043e\u0448\u043b\u0430 \u0432 \u043f\u0440\u043e\u0434 \u0438 \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0442\u043e, \u0447\u0442\u043e V1 \u043d\u0435 \u043c\u043e\u0433\u043b\u0430. \u0420\u0435\u0444\u0435\u0440\u0430\u043b\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0440\u0430\u0444\u0438\u043a \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u043f\u043b\u0430\u0442\u043d\u043e\u0439 \u0440\u0435\u043a\u043b\u0430\u043c\u044b, \u0438\u043d\u0444\u043b\u044e\u0435\u043d\u0441\u0435\u0440\u044b \u044d\u0442\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0438 \u0441\u0430\u043c\u0438 \u043d\u0430\u0447\u0430\u043b\u0438 \u0441\u0442\u0443\u0447\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c\u0438. \u0412 \u0434\u0430\u0448\u0431\u043e\u0440\u0434\u0430\u0445 \u043f\u0440\u043e\u0434\u0430\u043a\u0442\u0430 \u0438 \u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432 \u0446\u0438\u0444\u0440\u044b \u0432\u043f\u0435\u0440\u0432\u044b\u0435 \u0437\u0430 \u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u043a\u0430\u0437\u0430\u043b\u0438\u0441\u044c \u0437\u0435\u043b\u0451\u043d\u044b\u043c\u0438 \u0432 \u043e\u0434\u043d\u043e\u043c \u0438 \u0442\u043e\u043c \u0436\u0435 \u043a\u0432\u0430\u0440\u0442\u0430\u043b\u0435. \u041f\u0440\u043e\u0435\u043a\u0442 \u0436\u0438\u0432, \u043f\u0440\u043e\u0435\u043a\u0442 \u0440\u0430\u0441\u0442\u0451\u0442, \u043f\u0440\u043e\u0435\u043a\u0442 \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442.<\/p>\n<p>\u041f\u0440\u043e\u0434\u0430\u043a\u0442\u044b \u043b\u043e\u0432\u044f\u0442 \u0432\u043e\u043b\u043d\u0443 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043f\u043e\u0434\u0433\u043e\u043d\u044f\u0442\u044c: \u00ab\u043f\u0430\u0440\u043d\u0438, \u0440\u044b\u043d\u043e\u043a \u043e\u0442\u043a\u0440\u044b\u043b\u0441\u044f, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u044b \u043d\u0435 \u0441\u043f\u044f\u0442\u00bb. \u0412 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u043e\u0442, \u043a\u0442\u043e \u044d\u0442\u0443 \u0432\u043e\u043b\u043d\u0443 \u043b\u043e\u0432\u0438\u0442 \u0435\u0449\u0451 \u0438 \u043b\u0438\u0447\u043d\u043e. \u0421\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0443 \u0441\u0435\u0431\u044f \u0432 \u0433\u043e\u043b\u043e\u0432\u0435: \u0444\u0438\u0447\u0430 \u0431\u043e\u043b\u044c\u0448\u0430\u044f, \u0437\u0430\u043c\u0435\u0442\u043d\u0430\u044f, \u043a\u0430\u043a \u0440\u0430\u0437 \u043f\u0435\u0440\u0435\u0434 performance review; \u0435\u0441\u043b\u0438 \u0432\u044b\u043a\u0430\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u043c \u0438 \u0431\u0435\u0437 \u0431\u0430\u0433\u043e\u0432 \u2014 \u043c\u043e\u0436\u043d\u043e \u0438\u0434\u0442\u0438 \u043a \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0443 \u0438 \u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0442\u0438\u043c\u043b\u0438\u0434-\u0433\u0440\u0435\u0439\u0434, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u0432\u0441\u0442\u0440\u0435\u0447\u0438, \u0441\u0442\u0430\u0442\u044c \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u043c, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u043e\u0434\u0430\u043a\u0442 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0434\u0451\u0442 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c, \u0430 \u0443\u0436\u0435 \u043f\u043e\u0442\u043e\u043c \u043f\u0438\u0448\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0443\u044e \u0438\u0441\u0442\u043e\u0440\u0438\u044e. \u0421\u0442\u0438\u043c\u0443\u043b \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439, \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u043a\u0438\u0439 \u2014 \u043d\u0435 \u043f\u043b\u043e\u0445\u043e\u0439 \u0438 \u043d\u0435 \u0445\u043e\u0440\u043e\u0448\u0438\u0439, \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439.<\/p>\n<p>\u041d\u0430 \u0441\u0442\u043e\u043b \u043b\u0451\u0433 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0430\u043a\u0435\u0442 \u00ab\u0434\u0430\u0432\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0438\u0441\u044c\u00bb. \u041f\u0430\u0440\u0442\u043d\u0451\u0440\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441 \u0431\u043b\u043e\u0433\u0435\u0440\u0430\u043c\u0438 \u0438 \u0441\u0442\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438. \u0420\u0430\u0437\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043c\u043e\u043d\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u2014 revenue share, \u0431\u043e\u043d\u0443\u0441\u044b, \u0443\u0440\u043e\u0432\u043d\u0438. \u0410\u043d\u0442\u0438-\u0444\u0440\u043e\u0434 \u043f\u043e\u0441\u0435\u0440\u044c\u0451\u0437\u043d\u0435\u0435, \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f\u043c\u0438 \u0438 \u0441\u043a\u043e\u0440\u0438\u043d\u0433\u043e\u043c. \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u043f\u043e \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u0443, \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0443 \u0438 \u0444\u0438\u043d\u0430\u043d\u0441\u0430\u043c. \u0418 \u0435\u0449\u0451 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0435\u0444\u0435\u0440\u0430\u043b\u043e\u043a. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u2014 \u0440\u043e\u0432\u043d\u043e \u0442\u0430 \u0436\u0435 \u043b\u043e\u0433\u0438\u043a\u0430, \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432.<\/p>\n<p>\u041d\u0430\u0448 \u0433\u0435\u0440\u043e\u0439 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 <code>auth.service.ts<\/code> \u0438 \u043f\u0440\u043e\u0434\u0443\u043c\u044b\u0432\u0430\u0435\u0442 \u0441\u0430\u043c\u044b\u0439 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u0443\u0442\u044c \u2014 \u0432\u0441\u0451 \u0432 \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441, \u0431\u0435\u0437 \u043b\u0438\u0448\u043d\u0438\u0445 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u043e\u0432, \u0431\u0435\u0437 \u0441\u043f\u043e\u0440\u043e\u0432 \u043d\u0430 \u0440\u0435\u0432\u044c\u044e, \u043a \u043f\u044f\u0442\u043d\u0438\u0446\u0435 \u0434\u0435\u043f\u043b\u043e\u0439. \u0418 \u0432\u043e\u0442 \u0440\u043e\u0432\u043d\u043e \u044d\u0442\u0430 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u2014 \u0443\u0441\u043f\u0435\u0445 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430, \u0434\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0434\u0430\u043a\u0442\u043e\u0432, \u043b\u0438\u0447\u043d\u0430\u044f \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u0430 \u0438 \u043f\u044f\u0442\u043d\u0438\u0447\u043d\u044b\u0439 \u0434\u0435\u0434\u043b\u0430\u0439\u043d \u2014 \u0440\u0430\u0437 \u0437\u0430 \u0440\u0430\u0437\u043e\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0432\u0435\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u0434\u0430. \u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0432 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0448\u0451\u043b \u0438\u0437 MVP \u0432 \u0440\u043e\u0441\u0442, \u0432\u044b \u044d\u0442\u0443 \u0441\u0446\u0435\u043d\u0443 \u0432\u0438\u0434\u0435\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u0440\u0430\u0437. \u0421\u0435\u0439\u0447\u0430\u0441 \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0435\u0451 \u0435\u0449\u0451 \u0440\u0430\u0437 \u2014 \u0438 \u0432 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u044f\u0445.<\/p>\n<p>\u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u0447\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432 <code>auth.service.ts<\/code>, \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043b\u0435\u0436\u0438\u0442 \u0432 \u0422\u0417 \u043a \u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u0430\u043f\u0443:<\/p>\n<ol>\n<li>\n<p>\u041f\u0430\u0440\u0442\u043d\u0451\u0440\u0441\u043a\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441 \u0431\u043b\u043e\u0433\u0435\u0440\u0430\u043c\u0438 \u0438 \u0441\u0442\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438 \u043f\u0430\u0440\u0442\u043d\u0451\u0440\u043e\u0432, \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u0443\u0441\u044b \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u043d\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u2014 revenue share, \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0435 \u0431\u043e\u043d\u0443\u0441\u044b, \u0443\u0440\u043e\u0432\u043d\u0438 \u043f\u0430\u0440\u0442\u043d\u0451\u0440\u0441\u0442\u0432\u0430, \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043d\u0430\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u043b\u043e\u0436\u043d\u0451\u043d\u043d\u044b\u0439 \u0430\u043d\u0442\u0438-\u0444\u0440\u043e\u0434 \u2014 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 (\u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0440\u0435\u0444\u0435\u0440\u0430\u043b\u043a\u0430, \u043f\u0430\u0440\u0442\u043d\u0451\u0440\u0441\u043a\u0438\u0439 \u043a\u043b\u0438\u043a), \u0441\u043a\u043e\u0440\u0438\u043d\u0433\u043e\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c, \u0440\u0443\u0447\u043d\u044b\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043b\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u0430, \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0438 \u0444\u0438\u043d\u0430\u043d\u0441\u043e\u0432; \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0435\u0444\u0435\u0440\u0430\u043b\u043e\u043a \u2014 \u043b\u0438\u043c\u0438\u0442\u044b \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043f\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c \u0442\u0440\u0430\u0444\u0438\u043a\u0430<\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0443\u043d\u043a\u0442 \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441: \u043d\u0438\u0447\u0435\u0433\u043e \u044d\u043a\u0437\u043e\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e, \u043d\u0438\u0447\u0435\u0433\u043e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e-\u043f\u0440\u043e\u0432\u043e\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e. \u0418\u0445 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u043e\u0432\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b.<\/p>\n<h4>AuthService.signUp V3<\/h4>\n<pre><code class=\"typescript\">async signUp(  email: string,  password: string,  referralCode?: string,  adSourceCode?: string,  ip?: string,  deviceId?: string,): Promise&lt;SignUpResponse&gt; {  const existingUserByEmail = await this.usersRepository.findOne({    where: { email },  });  if (existingUserByEmail) {    throw new BadRequestException(\"User already exists\");  }  const registrationsFromIp = await this.usersRepository.count({    where: { registrationIp: ip },  });  if (registrationsFromIp &gt; 5) {    throw new BadRequestException(\"Too many registrations from this IP\");  }  const existingUserByDevice = await this.usersRepository.findOne({    where: { deviceId },  });  if (existingUserByDevice) {    throw new BadRequestException(\"Device already used\");  }  const fraudScore =    (registrationsFromIp ?? 0) * 10 +    (existingUserByDevice ? 50 : 0) +    (ip?.startsWith(\"192.\") ? 20 : 0);  if (fraudScore &gt; 70) {    throw new BadRequestException(\"Fraud detected\");  }  const adSource = adSourceCode    ? await this.adSourceRepository.findOne({ where: { code: adSourceCode } })    : null;  if (adSourceCode &amp;&amp; !adSource) {    throw new BadRequestException(\"Invalid ad source\");  }  if (adSource) {    const experimentGroup = Math.random() &gt; 0.5 ? \"A\" : \"B\";    await this.adSourceRepository.increment(      { id: adSource.id },      \"registrationsCount\",      1,    );    await this.analyticsRepository.save({      type: \"experiment_assignment\",      group: experimentGroup,      source: adSource.code,    });  }  const referral = referralCode    ? await this.referralsRepository.findOne({        where: { code: referralCode },        relations: [\"owner\", \"influencerPartner\"],      })    : null;  if (referralCode &amp;&amp; !referral) {    throw new BadRequestException(\"Invalid referral code\");  }  const influencerPartner = referral?.influencerPartner ?? null;  const referredByUser =    referral &amp;&amp; !influencerPartner ? referral.owner : null;  let calculatedReward = 0;  if (influencerPartner) {    await this.partnerRepository.increment(      { id: influencerPartner.id },      \"registrationsCount\",      1,    );    if (influencerPartner.type === \"blogger\") {      const audienceSize = influencerPartner.audienceSize ?? 1000;      const ctr = influencerPartner.ctr ?? 0.02;      const engagementScore = audienceSize * ctr;      calculatedReward =        20 + engagementScore * 0.01 + (engagementScore &gt; 1000 ? 50 : 0);      if (engagementScore &gt; 5000) {        calculatedReward *= 1.5;      }    } else if (influencerPartner.type === \"streamer\") {      const avgViewers = influencerPartner.avgViewers ?? 100;      const streamHours = influencerPartner.streamHours ?? 2;      const retentionFactor = Math.min(streamHours \/ 4, 1);      calculatedReward =        avgViewers * 0.5 * retentionFactor + (avgViewers &gt; 1000 ? 100 : 0);      if (streamHours &gt; 6) {        calculatedReward *= 1.2;      }    } else if (influencerPartner.type === \"partner\") {      const revenueShare = influencerPartner.revenueShare ?? 0.1;      const baseValue = influencerPartner.baseValue ?? 200;      const tierMultiplier =        influencerPartner.tier === \"gold\"          ? 2          : influencerPartner.tier === \"silver\"            ? 1.5            : 1;      calculatedReward = baseValue * revenueShare * tierMultiplier;      if (influencerPartner.kpiAchieved) {        calculatedReward += 300;      }    }    await this.analyticsRepository.save({      type: \"marketing_conversion\",      source: influencerPartner.type,      reward: calculatedReward,    });    await this.analyticsRepository.save({      type: \"revenue_projection\",      expectedRevenue: calculatedReward * 10,    });    await this.analyticsRepository.save({      type: \"user_segment\",      segment:        influencerPartner.type === \"streamer\" ? \"gamers\" : \"general\",    });  }  if (referredByUser) {    const referralsByOwnerCount = await this.referralsRepository.count({      where: { owner: { id: referredByUser.id } },    });    if (referralsByOwnerCount &gt; 10) {      throw new BadRequestException(\"Referral limit exceeded\");    }    const existingReferralForEmail = await this.referralsRepository.findOne({      where: {        owner: { id: referredByUser.id },        invitedUser: { email },      },      relations: [\"invitedUser\"],    });    if (existingReferralForEmail) {      throw new BadRequestException(\"Referral abuse detected\");    }    if (referredByUser.email === email) {      throw new BadRequestException(\"Self-referral not allowed\");    }  }  const newUser = this.usersRepository.create({    email,    password,    adSource,    registrationIp: ip,    deviceId,    isVerified: false,  });  await this.usersRepository.save(newUser);  if (referredByUser) {    await this.bonusRepository.save({      userId: referredByUser.id,      amount: 100,      type: \"referral_reward\",    });    const parentReferral = await this.referralsRepository.findOne({      where: { invitedUser: { id: referredByUser.id } },      relations: [\"owner\"],    });    if (parentReferral) {      await this.bonusRepository.save({        userId: parentReferral.owner.id,        amount: 50,        type: \"second_level_referral\",      });    }    await this.referralsRepository.save({      owner: referredByUser,      invitedUser: newUser,    });  }  if (influencerPartner) {    const partnerOwner = await this.usersRepository.findOne({      where: { id: influencerPartner.ownerUserId },    });    if (partnerOwner) {      await this.bonusRepository.save({        userId: partnerOwner.id,        amount: calculatedReward,        type: \"influencer_reward\",      });      await this.analyticsRepository.save({        type: \"influencer_reward_paid\",        partnerId: influencerPartner.id,        amount: calculatedReward,      });    }  }  await this.analyticsRepository.save({    type: \"user_registered\",    userId: newUser.id,    source: adSource?.code,    ip,  });  return {    id: newUser.id,    email: newUser.email,  };}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u042d\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u044c \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430 \u043d\u0435\u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u2014 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432\u0438\u0434\u043d\u044b \u043d\u0435\u0432\u043e\u043e\u0440\u0443\u0436\u0451\u043d\u043d\u044b\u043c \u0433\u043b\u0430\u0437\u043e\u043c. \u0414\u0432\u0435\u0441\u0442\u0438 \u0441\u0442\u0440\u043e\u043a \u0432 \u043e\u0434\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0448\u0435\u0441\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435, \u0442\u0440\u0438 \u0432\u0435\u0442\u043a\u0438 \u0440\u0435\u0444\u0435\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0438, \u0442\u0440\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432\u043e\u0437\u043d\u0430\u0433\u0440\u0430\u0436\u0434\u0435\u043d\u0438\u044f \u043f\u0430\u0440\u0442\u043d\u0451\u0440\u043e\u0432; \u0437\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u2014 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0431\u0438\u0437\u043d\u0435\u0441-\u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0439, \u0438 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u0445 \u0432 \u0433\u043e\u043b\u043e\u0432\u0435 \u043d\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043d\u0438 \u043e\u0434\u0438\u043d \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043a\u0440\u043e\u043c\u0435 \u0430\u0432\u0442\u043e\u0440\u0430. \u0421\u0442\u043e\u0438\u0442 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u043d\u0443\u0442\u044c, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u0434\u0435 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u043d\u043e \u043e\u043f\u0443\u0449\u0435\u043d\u044b \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0441\u0442\u044c, \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c, \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432, \u0435\u0434\u0438\u043d\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u0438 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0434\u044b \u043e\u0442\u0432\u0435\u0442\u0430: \u0438\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u043e \u0431\u044b \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c, \u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u043e\u043b\u0435\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u043e\u0439.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0443 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u0430\u044f \u043c\u044b\u0441\u043b\u044c: \u00ab\u0425\u043e\u0440\u043e\u0448\u043e, \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u0430 \u2014 AuthService \u0434\u0435\u0440\u0436\u0438\u0442 \u043b\u043e\u0433\u0438\u043a\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0445 \u0434\u043e\u043c\u0435\u043d\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435. \u0417\u043d\u0430\u0447\u0438\u0442, \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0432\u0435\u0441\u0442\u0438 UsersService, ReferralsService, MarketingService, FraudService, PartnerService \u0438 \u0440\u0430\u0437\u043d\u0435\u0441\u0442\u0438 \u043f\u043e \u043d\u0438\u043c \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 signUp \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u043e\u0434\u0438\u043d \u0441\u0435\u0440\u0432\u0438\u0441 \u2014 \u043e\u0434\u0438\u043d \u0434\u043e\u043c\u0435\u043d; AuthService \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0440\u043a\u0435\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u043e\u043c\u00bb. \u042d\u0442\u043e\u0442 \u043e\u0442\u0432\u0435\u0442 \u2014 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f NestJS-\u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0438 \u0431\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043e\u0432\u0435\u0442 \u043d\u0430 \u043b\u044e\u0431\u043e\u043c \u0440\u0435\u0432\u044c\u044e \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u041e\u043d \u0437\u0432\u0443\u0447\u0438\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0430\u0451\u0442 \u0432\u0438\u0434\u0438\u043c\u043e\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0422\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043e\u043d \u043d\u0435 \u0440\u0435\u0448\u0430\u0435\u0442. \u0418 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u0440\u043e\u0439\u0434\u0451\u043c \u043f\u043e \u0442\u0430\u043a\u043e\u043c\u0443 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0443 \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c \u0438 \u0443\u0432\u0438\u0434\u0438\u043c, \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u043d\u0435\u0441\u0442\u0438 \u043f\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u2014 \u044d\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0438\u0437 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430 \u0432 \u0434\u0440\u0443\u0433\u043e\u0435, \u0438 \u043b\u044e\u0431\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430 \u00ab\u0434\u0435\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u044b\u00bb \u043d\u0435\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u0447\u0435\u0440\u0435\u0437 \u0442\u043e\u0442 \u0436\u0435 \u0433\u043e\u0434 \u0441\u043d\u043e\u0432\u0430 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u0432 \u0442\u043e\u0439 \u0436\u0435 \u0442\u043e\u0447\u043a\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0434\u0440\u0443\u0433\u0438\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0438\u043c\u0451\u043d \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<\/div>\n<p>\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\/articles\/1038240\/\">https:\/\/habr.com\/ru\/articles\/1038240\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u0430\u044f \u0434\u043e\u043a\u0442\u0440\u0438\u043d\u0430 \u0434\u043b\u044f NestJS-\u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432: \u0440\u0430\u0437\u0431\u043e\u0440 \u0442\u0438\u043f\u043e\u0432\u044b\u0445 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432 \u0434\u0435\u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u0435\u0451 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u043f\u0440\u0438 \u0440\u043e\u0441\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430.\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u2014 \u0440\u0430\u0437\u0431\u043e\u0440 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u0431\u044d\u043a\u0435\u043d\u0434 \u043d\u0430 NestJS \u0434\u0435\u0433\u0440\u0430\u0434\u0438\u0440\u0443\u0435\u0442 \u0441 \u0440\u043e\u0441\u0442\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u0438 \u043a\u0430\u043a \u0438\u0434\u0435\u0438 Clean Architecture \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u044d\u0442\u043e\u0433\u043e \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c. \u042f \u043f\u0440\u043e\u0439\u0434\u0443 \u043f\u043e \u043f\u043e\u043b\u043d\u043e\u043c\u0443 \u0446\u0438\u043a\u043b\u0443: \u043f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u00ab\u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435\u00bb, \u043a\u0430\u043a feature-based-\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u044e\u0442 \u043a\u0430\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442, \u0442\u0435\u0440\u044f\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0441\u0442\u044c \u0441 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u043e\u043c; \u0440\u0430\u0437\u0431\u0435\u0440\u0443 \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0434\u0435\u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438; \u043e\u0446\u0435\u043d\u044e \u0432 \u0434\u0435\u043d\u044c\u0433\u0430\u0445 \u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e-\u0447\u0430\u0441\u0430\u0445, \u0432\u043e \u0447\u0442\u043e \u043e\u043d\u0438 \u043e\u0431\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0431\u0438\u0437\u043d\u0435\u0441\u0443; \u043e\u0431\u044a\u044f\u0441\u043d\u044e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a\u0430\u044f \u043a\u043e\u0434\u043e\u0432\u0430\u044f \u0431\u0430\u0437\u0430 \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0434\u0440\u043e\u0431\u0438\u0442\u044c \u043c\u043e\u043d\u043e\u043b\u0438\u0442 \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0437\u0430\u0434\u043e\u043b\u0433\u043e \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u044f \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0443 \u043f\u043e\u0434\u0445\u043e\u0434, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u0438\u0432 \u0434\u0435\u0433\u0440\u0430\u0434\u0430\u0446\u0438\u0438, \u2014 \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043e\u0431\u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435. \u041a \u043a\u043e\u043d\u0446\u0443 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443 \u0432\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f, \u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0441\u0432\u043e\u0438\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c.\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0441\u043a\u0432\u043e\u0437\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0432\u043e\u0437\u044c\u043c\u0451\u043c \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u044e\u0442 \u043d\u0430 System Design-\u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u0438\u0437 \u0440\u0430\u0437\u0430 \u0432 \u0440\u0430\u0437: \u0431\u044d\u043a\u0435\u043d\u0434 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 Twitter. \u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0447\u0435\u0432\u0438\u0434\u0435\u043d \u2014 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u0412\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0448\u0430\u0440\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u0441\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0435\u043c \u0437\u0430 \u0441\u043a\u043e\u0431\u043a\u0438: \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043a\u043e\u0434\u0430, \u0430 \u043d\u0435 \u043f\u0440\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043d\u0443\u044e \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c. \u0421\u0442\u0435\u043a \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u2014 Node.js \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a NestJS. \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0441\u0438\u0441\u0442\u0435\u043c\u0435.\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0432\u0438\u0442\u0430\u041b\u0435\u043d\u0442\u0430 (feed)\u041f\u043e\u0434\u043f\u0438\u0441\u043a\u0438 (follow \/ unfollow)\u041f\u0440\u043e\u0444\u0438\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u041b\u0430\u0439\u043a\u0438\u0420\u0435\u0442\u0432\u0438\u0442\u044b\u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 (replies)\u041f\u043e\u0438\u0441\u043a (\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0442\u0432\u0438\u0442\u043e\u0432, \u0445\u044d\u0448\u0442\u0435\u0433\u043e\u0432)\u0423\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f (\u043b\u0430\u0439\u043a\u0438, \u043f\u043e\u0434\u043f\u0438\u0441\u043a\u0438, \u043e\u0442\u0432\u0435\u0442\u044b)\u041c\u0435\u0434\u0438\u0430 (\u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \/ \u0432\u0438\u0434\u0435\u043e)\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 Twitter \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0438 \u0441\u0442\u0440\u043e\u0438\u043b\u0441\u044f \u0433\u043e\u0434\u0430\u043c\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432 \u0441\u043e\u0442\u043d\u0438 \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u0432 \u2014 \u043d\u043e \u0446\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u043e\u0434\u0443\u043a\u0442, \u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u0443\u044e \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044e \u043d\u0430 \u0437\u043d\u0430\u043a\u043e\u043c\u043e\u0439 \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438. \u0421\u043f\u0438\u0441\u043e\u043a \u0444\u0438\u0447 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d, \u0441\u0445\u0435\u043c\u0430 \u0431\u0430\u0437\u044b \u0438 \u043d\u0430\u0431\u043e\u0440 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u043e\u0432 \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0435\u0437 \u0440\u0430\u0437\u0434\u0443\u043c\u0438\u0439, \u0441\u0442\u0435\u043a \u0432\u044b\u0431\u0440\u0430\u043d. \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e NestJS \u2014 \u0438 \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u0436\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0430\u043c \u043e\u043f\u043e\u0440\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.src\/\u251c\u2500\u2500 main.ts\u251c\u2500\u2500 app.module.ts\u2502\u251c\u2500\u2500 modules\/\u2502   \u251c\u2500\u2500 auth\/\u2502   \u251c\u2500\u2500 users\/\u2502   \u251c\u2500\u2500 tweets\/\u2502   \u251c\u2500\u2500 feed\/\u2502   \u251c\u2500\u2500 likes\/\u2502   \u251c\u2500\u2500 comments\/\u2502   \u251c\u2500\u2500 retweets\/\u2502   \u251c\u2500\u2500 follows\/\u2502   \u251c\u2500\u2500 notifications\/\u2502   \u251c\u2500\u2500 search\/\u2502   \u2514\u2500\u2500 media\/\u2502\u251c\u2500\u2500 common\/\u2502   \u251c\u2500\u2500 guards\/\u2502   \u251c\u2500\u2500 interceptors\/\u2502   \u251c\u2500\u2500 filters\/\u2502   \u251c\u2500\u2500 decorators\/\u2502   \u2514\u2500\u2500 utils\/\u2502\u251c\u2500\u2500 database\/\u2502   \u251c\u2500\u2500 prisma\/ \u0438\u043b\u0438 typeorm\/\u2502   \u2514\u2500\u2500 migrations\/\u2502\u251c\u2500\u2500 config\/\u2502   \u2514\u2500\u2500 configuration.ts\u041f\u043e\u043c\u0438\u043c\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043e\u0441\u0442\u0430\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u2014 \u043a\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0438 \u0432 \u043a\u0430\u043a\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c. \u042d\u0442\u0430 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430 \u0434\u043b\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u0441 \u0440\u0430\u0437\u043d\u043e\u0439 \u043f\u0440\u0438\u0440\u043e\u0434\u043e\u0439: \u0438 auth, \u0438 tweets, \u0438 search \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0438 \u0442\u043e\u043c\u0443 \u0436\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u0443. \u041f\u043e\u043a\u0430\u0436\u0443 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0434\u0443\u043b\u044f tweets:src\/modules\/tweets\/\u251c\u2500\u2500 tweets.module.ts\u251c\u2500\u2500 tweets.controller.ts\u251c\u2500\u2500 tweets.service.ts\u251c\u2500\u2500 dto\/\u2502   \u2514\u2500\u2500 create-tweet.dto.ts\u251c\u2500\u2500 entities\/\u2502   \u2514\u2500\u2500 tweet.entity.ts\u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u0441\u0445\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e: \u044f\u0441\u043d\u043e\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f, \u043d\u0438\u0437\u043a\u0438\u0439 \u043f\u043e\u0440\u043e\u0433 \u0432\u0445\u043e\u0434\u0430 \u0434\u043b\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0436\u0435 \u2014 \u0431\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043d\u043e\u0439 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u044b \u2014 \u043e\u043d\u0430 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u0433\u043e\u0434\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0440\u0443\u0434\u043d\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u043a\u043e\u0434. \u0414\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e: \u0448\u0430\u0433 \u0437\u0430 \u0448\u0430\u0433\u043e\u043c, \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439. \u041d\u0430\u0447\u043d\u0451\u043c \u0441 \u043c\u043e\u0434\u0443\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0441\u0442\u044c \u043f\u043e\u0447\u0442\u0438 \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435 \u2014 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f.\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b: \u0434\u0432\u0435 \u0440\u0443\u0447\u043a\u0438 \u2014 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0438 \u0432\u0445\u043e\u0434.@Controller(&#171;auth&#187;)export class AuthController {  constructor(private readonly authService: AuthService) {}  @Post(&#171;sign-up&#187;)  async signUp(@Body() dto: SignUpDto): Promise&lt;SignUpResponse&gt; {    return this.authService.signUp(dto.email, dto.password);  }  @Post(&#171;sign-in&#187;)  async signIn(@Body() dto: SignInDto): Promise&lt;SignInResponse&gt; {    return this.authService.signIn(dto.email, dto.password);  }}\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 ORM \u043f\u043e \u0445\u043e\u0434\u0443 \u0441\u0442\u0430\u0442\u044c\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c TypeORM \u2014 \u0432\u044b\u0431\u043e\u0440 \u043d\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0438\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0430 \u043e\u0431 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435, \u0438 \u0432\u0441\u0451, \u0447\u0442\u043e \u043d\u0438\u0436\u0435, \u043b\u0435\u0433\u043a\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043d\u0430 Prisma, MikroORM \u0438\u043b\u0438 Drizzle. \u041f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u0435\u043d \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0438\u0448\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.@Entity(&#171;users&#187;)export class User {  @PrimaryGeneratedColumn(&#171;uuid&#187;)  id: string;  @Column({ unique: true })  email: string;  @Column()  password: string;  @CreateDateColumn()  createdAt: Date;}\u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u0440\u0438\u043d\u044f\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435, \u043a\u043e\u0434, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0439\u0441\u044f \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438, \u0434\u043e\u043b\u0436\u0435\u043d \u0436\u0438\u0442\u044c \u0432 src\/modules\/users. \u0417\u043d\u0430\u0447\u0438\u0442, \u0438 \u043b\u043e\u0433\u0438\u043a\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e. \u042d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435\u043f\u043b\u043e\u0445\u0430\u044f \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u0430 \u2014 \u043b\u0443\u0447\u0448\u0435, \u0447\u0435\u043c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u044f\u043c\u043e \u0432 AuthService. \u041d\u043e \u0432 \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430: \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 AuthService \u0438\u043b\u0438 \u0445\u043e\u0434\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 UsersService. \u041d\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0435 \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0438 \u043e\u0431\u0430 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442 \u0440\u0435\u0432\u044c\u044e \u2014 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0445 \u0440\u044f\u0434\u043e\u043c.@Injectable()export class AuthService {  constructor(    @InjectRepository(User)    private readonly usersRepository: Repository&lt;User&gt;,  ) {}  async signUp(email: string, password: string) {    const existing = await this.usersRepository.findOne({      where: { email },    });    if (existing) {      throw new Error(&#171;User already exists&#187;);    }    const user = this.usersRepository.create({      email,      password,    });    await this.usersRepository.save(user);    return {      id: user.id,      email: user.email,    };  }  async signIn(email: string, password: string) {    const user = await this.usersRepository.findOne({      where: { email },    });    if (!user) {      throw new UnauthorizedException(&#171;Invalid credentials&#187;);    }    if (user.password !== password) {      throw new UnauthorizedException(&#171;Invalid credentials&#187;);    }    return {      id: user.id,      email: user.email,    };  }}\u041e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0432\u0438\u0441import { Injectable, UnauthorizedException } from &#171;@nestjs\/common&#187;;import { UsersService } from &#171;..\/users\/users.service&#187;;@Injectable()export class AuthService {  constructor(private readonly usersService: UsersService) {}  async signUp(email: string, password: string) {    const existing = await this.usersService.findByEmail(email);    if (existing) {      throw new Error(&#171;User already exists&#187;);    }    const user = await this.usersService.create({      email,      password,    });    return {      id: user.id,      email: user.email,    };  }  async signIn(email: string, password: string) {    const user = await this.usersService.findByEmail(email);    if (!user) {      throw new UnauthorizedException(&#171;Invalid credentials&#187;);    }    if (user.password !== password) {      throw new UnauthorizedException(&#171;Invalid credentials&#187;);    }    return {      id: user.id,      email: user.email,    };  }}\u041d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0435 \u043e\u0431\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u0440\u0430\u0432\u043d\u043e\u043f\u0440\u0430\u0432\u043d\u044b\u043c\u0438, \u0438 \u0432 \u044d\u0442\u043e\u043c \u0438 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u043b\u043e\u0432\u0443\u0448\u043a\u0430: \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0432\u044b\u0431\u043e\u0440 \u0441\u0435\u0439\u0447\u0430\u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u0442\u0435\u043c, \u043a\u0430\u043a \u043a\u043e\u0434 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0441\u044f \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u0430 \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0441 \u043d\u0438\u043c \u0447\u0435\u0440\u0435\u0437 \u0433\u043e\u0434. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u043c\u043e\u0442\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u0432\u043f\u0435\u0440\u0451\u0434 \u2014 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0448\u043b\u043e \u043e\u043a\u043e\u043b\u043e \u0433\u043e\u0434\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041f\u0440\u043e\u0434\u0443\u043a\u0442 \u043d\u0430\u0448\u0451\u043b \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u044e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0441\u0442\u0430\u043b\u043e \u043c\u043d\u043e\u0433\u043e, \u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c\u0438 \u043f\u0440\u0438\u0448\u043b\u0438 \u0438 \u0442\u0435, \u043a\u0442\u043e \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0430\u0431\u044c\u044e\u0437\u0438\u0442\u044c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e. \u041c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0438 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c A\/B-\u0442\u0435\u0441\u0442\u044b \u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u0445. \u041f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043c\u043d\u043e\u0433\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u0430\u044f \u0440\u0435\u0444\u0435\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441 \u0431\u043e\u043d\u0443\u0441\u0430\u043c\u0438 \u0438 \u043b\u0438\u043c\u0438\u0442\u0430\u043c\u0438. \u041c\u043e\u0434\u0443\u043b\u044c users \u043e\u0431\u0440\u043e\u0441 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0430\u043c\u0438 \u0438 \u043d\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438 \u2014 \u0441\u043b\u043e\u0432\u043e\u043c, \u0432\u0441\u0451 \u0442\u043e, \u0447\u0442\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u043e\u0432\u043d\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442\u044c \u0434\u0435\u043d\u044c\u0433\u0438.\u0417\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e, \u043a \u043a\u0430\u043a\u043e\u043c\u0443 \u0441\u043f\u0438\u0441\u043a\u0443 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0439 \u043d\u0443\u0436\u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c AuthService:\u0420\u0435\u0444\u0435\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438: \u043b\u0438\u043c\u0438\u0442\u044b \u043d\u0430 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u044f, \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 self-referral, \u0437\u0430\u0449\u0438\u0442\u0430 \u043e\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0439 \u0442\u043e\u0433\u043e \u0436\u0435 email\u0423\u0441\u043b\u043e\u0436\u043d\u0438\u0432\u0448\u0430\u044f\u0441\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441 \u0430\u043d\u0442\u0438-\u0430\u0431\u044c\u044e\u0437-\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430\u043c\u0438 \u2014 \u043f\u043e IP, \u043f\u043e deviceId, \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0441 \u0442\u043e\u0433\u043e \u0436\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u0420\u0430\u0441\u0448\u0438\u0440\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u044c users \u2014 \u043d\u043e\u0432\u044b\u0435 \u043f\u043e\u043b\u044f (\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0442\u0440\u0430\u0444\u0438\u043a\u0430, deviceId, \u0444\u043b\u0430\u0433\u0438 \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438), \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u044b, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u0430 \u2014 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0439, A\/B-\u0442\u0435\u0441\u0442\u044b, \u0444\u0438\u043a\u0441\u0430\u0446\u0438\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 \u0442\u0440\u0430\u0444\u0438\u043a\u0430, \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u0439\u041e\u0433\u043e\u0432\u043e\u0440\u043a\u0430 \u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f\u0445. \u0412 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0434\u0435\u043c\u043f\u043e\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u0449\u0438\u0442\u044b \u043e\u0442 \u0433\u043e\u043d\u043e\u043a \u0438 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0438. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0441\u0442\u0430\u0442\u044c\u0438 \u0432\u0441\u0451 \u044d\u0442\u043e \u0441\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u043f\u0443\u0449\u0435\u043d\u043e \u2014 \u0440\u0435\u0447\u044c \u043e \u0434\u0435\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0430 \u043d\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u043e\u0441\u0442\u0438. \u0418 \u0441\u0440\u0430\u0437\u0443 \u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043b\u043e\u0432\u0438\u0442\u044c \u0432\u043e\u043f\u0440\u043e\u0441: \u00ab\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0432\u0441\u0451 \u044d\u0442\u043e \u043e\u0434\u043d\u043e\u0439 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0435\u0439\u00bb \u2014 \u0442\u043e\u0436\u0435 \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 default. \u0414\u043b\u0438\u043d\u043d\u044b\u0439 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u0441 \u043f\u043e\u0445\u043e\u0434\u043e\u043c \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u044e\u044e \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443, \u0431\u043e\u043d\u0443\u0441\u0430\u043c\u0438 \u0438 \u043f\u0435\u0440\u0435\u0441\u0447\u0451\u0442\u043e\u043c \u0441\u0447\u0451\u0442\u0447\u0438\u043a\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u043c\u0438 \u0438 \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0440\u043e\u043d\u044f\u0435\u0442 \u0431\u0430\u0437\u0443. \u041a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0430 \u2014 \u044d\u0442\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430, \u0432\u044b\u0445\u043e\u0434\u044f\u0449\u0430\u044f \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u0441\u0442\u0430\u0442\u044c\u0438.AuthService.signUp V2async signUp(  email: string,  password: string,  referralCode?: string,  adSourceCode?: string,  ip?: string,  deviceId?: string,): Promise&lt;SignUpResponse&gt; {  const existingUserByEmail = await this.usersRepository.findOne({    where: { email },  });  if (existingUserByEmail) {    throw new BadRequestException(&#171;User already exists&#187;);  }  const registrationsFromIp = await this.usersRepository.count({    where: { registrationIp: ip },  });  if (registrationsFromIp &gt; 5) {    throw new BadRequestException(&#171;Too many registrations from this IP&#187;);  }  const existingUserByDevice = await this.usersRepository.findOne({    where: { deviceId },  });  if (existingUserByDevice) {    throw new BadRequestException(&#171;Device already used&#187;);  }  const adSource = adSourceCode    ? await this.adSourceRepository.findOne({ where: { code: adSourceCode } })    : null;  if (adSourceCode &amp;&amp; !adSource) {    throw new BadRequestException(&#171;Invalid ad source&#187;);  }  if (adSource) {    const experimentGroup = Math.random() &gt; 0.5 ? &#171;A&#187; : &#171;B&#187;;    await this.adSourceRepository.increment(      { id: adSource.id },      &#171;registrationsCount&#187;,      1,    );    await this.analyticsRepository.save({      type: &#171;experiment_assignment&#187;,      group: experimentGroup,    &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-480675","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/480675","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=480675"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/480675\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=480675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=480675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=480675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}