{"id":315489,"date":"2020-12-24T15:01:43","date_gmt":"2020-12-24T15:01:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=315489"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=315489","title":{"rendered":"\u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u0442\u0435\u043a \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0437\u0430\u0434\u0430\u0447 (React, Vue, TypeScript, Express, Mongoose)"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ig\/mq\/2d\/igmq2dvqrh3pvqpohaicef0c3zi.png\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0443\u043b\u043b\u0441\u0442\u0435\u043a-\u0442\u0443\u0434\u0443\u0448\u043a\u0443.<\/p>\n<p>  \u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b:<\/p>\n<ul>\n<li>\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a<\/li>\n<li>\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438<\/li>\n<li>\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/li>\n<li>\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430<\/li>\n<li>\u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u0434\u0430\u0447: \u0432\u0441\u0435, \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435, \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0435<\/li>\n<li>\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<\/ul>\n<p>  \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/nd\/st\/7k\/ndst7klmkvjcdjvlam_ewm9ylaa.png\"><br \/>  \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u043e\u0445\u0432\u0430\u0442\u0430 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c JavaScript, \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u2014 \u043d\u0430 Node.js. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u043e\u0434\u044b \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d Express.js, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (Local Storage), \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (IndexedDB) \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043e\u0431\u043b\u0430\u0447\u043d\u0430\u044f MongoDB.<\/p>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u043b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0435 \u0442\u0430\u043a\u0438\u043c\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u043c\u0438, \u043a\u0430\u043a React \u0438 Vue: \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043d\u0430 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u043b\u0438\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u0438 \u0442.\u0434. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u0434\u0435\u0440\u0436\u0438\u043c\u0441\u044f \u043e\u0442 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u044f HTML, CSS \u0438 JavaScript.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043d\u0430 React \u0438 Vue, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0444\u0443\u043b\u043b\u0441\u0442\u0435\u043a-\u0442\u0443\u0434\u0443\u0448\u043a\u0438 \u043d\u0430 React + TypeScript + Express + Mongoose.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u0441\u0435\u0445 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"https:\/\/github.com\/harryheman\/FullStack-Todos-App\" rel=\"nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  \u041a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f <a href=\"https:\/\/github.com\/harryheman\/FullStack-Todos-App\/tree\/main\/javascript-express-mongoose\" rel=\"nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  \u0414\u0435\u043c\u043e \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<div class=\"oembed\"><iframe id=\"5fe32d573b295d140fdb393b\" src=\"https:\/\/embedd.srv.habr.com\/iframe\/5fe32d573b295d140fdb393b\"><\/iframe><\/div>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u043e\u0435\u0445\u0430\u043b\u0438.<\/p>\n<h3>\u041a\u043b\u0438\u0435\u043d\u0442<\/h3>\n<p>  \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, javascript-express-mongoose:<\/p>\n<pre><code class=\"javascript\">mkdir javascript-express-mongoose cd !$ code . <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e client. \u0412 \u044d\u0442\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0432\u0435\u0441\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c index.html. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0430\u043f\u043a\u0438 \u0438 \u0444\u0430\u0439\u043b\u044b:<\/p>\n<pre><code class=\"javascript\">client   components     Buttons.js     Form.js     Item.js     List.js   src     helpers.js     idb.js     router.js     storage.js   script.js   style.css <\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c index.html \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"xml\">&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt;   &lt;head&gt;     &lt;meta charset=&quot;UTF-8&quot; \/&gt;     &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; \/&gt;     &lt;title&gt;JS Todos App&lt;\/title&gt;     &lt;!-- \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u0442\u0438\u043b\u0438 --&gt;     &lt;link rel=&quot;stylesheet&quot; href=&quot;client\/style.css&quot; \/&gt;   &lt;\/head&gt;   &lt;body&gt;     &lt;div id=&quot;root&quot;&gt;&lt;\/div&gt;      &lt;!-- \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 --&gt;     &lt;script src=&quot;client\/script.js&quot; type=&quot;module&quot;&gt;&lt;\/script&gt;   &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0421\u0442\u0438\u043b\u0438 (client\/style.css):<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"css\">@import url('https:\/\/fonts.googleapis.com\/css2?family=Stylish&amp;display=swap');  * {   margin: 0;   padding: 0;   box-sizing: border-box;   font-family: stylish;   font-size: 1rem;   color: #222; }  #root {   max-width: 512px;   margin: auto;   text-align: center; }  #title {   font-size: 2.25rem;   margin: 0.75rem; }  #counter {   font-size: 1.5rem;   margin-bottom: 0.5rem; }  #form {   display: flex;   margin-bottom: 0.25rem; }  #input {   flex-grow: 1;   border: none;   border-radius: 4px;   box-shadow: 0 0 1px inset #222;   text-align: center;   font-size: 1.15rem;   margin: 0.5rem 0.25rem; }  #input:focus {   outline-color: #5bc0de; }  .btn {   border: none;   outline: none;   background: #337ab7;   padding: 0.5rem 1rem;   border-radius: 4px;   box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);   color: #eee;   margin: 0.5rem 0.25rem;   cursor: pointer;   user-select: none;   width: 102px;   text-shadow: 0 0 1px rgba(0, 0, 0, 0.5); }  .btn:active {   box-shadow: 0 0 1px rgba(0, 0, 0, 0.5) inset; }  .btn.info {   background: #5bc0de; }  .btn.success {   background: #5cb85c; }  .btn.warning {   background: #f0ad4e; }  .btn.danger {   background: #d9534f; }  .btn.filter {   background: none;   color: #222;   text-shadow: none;   border: 1px dashed #222;   box-shadow: none; }  .btn.filter.checked {   border: 1px solid #222; }  #list {   list-style: none; }  .item {   display: flex;   flex-wrap: wrap;   justify-content: space-between;   align-items: center; }  .item + .item {   border-top: 1px dashed rgba(0, 0, 0, 0.5); }  .text {   flex: 1;   font-size: 1.15rem;   margin: 0.5rem;   padding: 0.5rem;   background: #eee;   border-radius: 4px; }  .completed .text {   text-decoration: line-through;   color: #888; }  .disabled {   opacity: 0.8;   position: relative;   z-index: -1; }  #modal {   position: absolute;   top: 10px;   left: 10px;   padding: 0.5em 1em;   background: rgba(0, 0, 0, 0.5);   border-radius: 4px;   font-size: 1.2em;   color: #eee; } <\/code><\/pre>\n<p>  <\/div>\n<\/p><\/div>\n<p>  \u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 (\u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u044b \u0437\u0435\u043b\u0435\u043d\u044b\u043c, \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u2014 \u0441\u0438\u043d\u0438\u043c):<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/le\/ew\/ev\/leewevg6tfvo8pw-lduzvqfybio.png\"><br \/>  \u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b: 1) \u0444\u043e\u0440\u043c\u0430, \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0430\u044f \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u043a\u043d\u043e\u043f\u043a\u0443 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a; 2) \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438 \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u0447; 3) \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447. \u0422\u0430\u043a\u0436\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043c\u044b \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430 \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b: 1) \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a; 2) \u0441\u0447\u0435\u0442\u0447\u0438\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043d\u0435\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<p>  \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 (\u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437). \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b Form \u0438 Buttons \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438, \u0430 List \u0438 Item \u2014 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438. \u0412 \u0446\u0435\u043b\u044f\u0445 \u0434\u0438\u0444\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0430\u0446\u0438\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f\/\u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0430 \u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\/\u0438\u043c\u043f\u043e\u0440\u0442.<\/p>\n<p>  client\/Form.js:<\/p>\n<pre><code class=\"javascript\">export default \/*html*\/ ` &lt;div id=&quot;form&quot;&gt;   &lt;input       type=&quot;text&quot;       autocomplete=&quot;off&quot;       autofocus       id=&quot;input&quot;   &gt;   &lt;button     class=&quot;btn&quot;     data-btn=&quot;add&quot;   &gt;     Add   &lt;\/button&gt; &lt;\/div&gt; ` <\/code><\/pre>\n<p>  \/*html*\/ \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0443 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u0443\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f VSCode es6-string-html. \u0410\u0442\u0440\u0438\u0431\u0443\u0442 data-btn \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043d\u043e\u043f\u043a\u0443 \u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u0435.<\/p>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b id \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a DOM-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b (\u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c\u0438), \u043f\u0440\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u0435 \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 (\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 window). \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>  client\/Buttons.js:<\/p>\n<pre><code class=\"javascript\">export default \/*html*\/ ` &lt;div id=&quot;buttons&quot;&gt;   &lt;button     class=&quot;btn filter checked&quot;     data-btn=&quot;all&quot;   &gt;     All   &lt;\/button&gt;   &lt;button     class=&quot;btn filter&quot;     data-btn=&quot;active&quot;   &gt;     Active   &lt;\/button&gt;   &lt;button     class=&quot;btn filter&quot;     data-btn=&quot;completed&quot;   &gt;     Completed   &lt;\/button&gt; &lt;\/div&gt; ` <\/code><\/pre>\n<p>  \u041a\u043d\u043e\u043f\u043a\u0438 \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u0443\u0434\u0443\u0448\u0435\u043a \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0432\u0441\u0435, \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 (\u043d\u0435\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0435) \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0435 (\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0435) \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  client\/Item.js (\u0441\u0430\u043c\u044b\u0439 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b):<\/p>\n<pre><code class=\"javascript\">\/**  * \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0443,  * \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442,  * \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0449\u0438\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440, \u0442\u0435\u043a\u0441\u0442 \u0438 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f  *  * \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438  * \u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u043a\u043d\u043e\u043f\u043a\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438  *  * \u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0447\u0435\u0440\u043a\u043d\u0443\u0442,  * \u0430 \u043a\u043d\u043e\u043f\u043a\u0430 \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f (\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f) \u0442\u0435\u043a\u0441\u0442\u0430 \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 - \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0430  *  * \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 *\/ export const Item = ({ id, text, done }) =&gt; \/*html*\/ ` &lt;li   class=&quot;item ${done ? 'completed' : ''}&quot;   data-id=&quot;${id}&quot; &gt;   &lt;button     class=&quot;btn ${done ? 'warning' : 'success'}&quot;     data-btn=&quot;complete&quot;   &gt;     ${done ? 'Cancel' : 'Complete'}   &lt;\/button&gt;   &lt;span class=&quot;text&quot;&gt;     ${text}   &lt;\/span&gt;   &lt;button     class=&quot;btn info ${done ? 'disabled' : ''}&quot;     data-btn=&quot;update&quot;   &gt;     Update   &lt;\/button&gt;   &lt;button     class=&quot;btn danger&quot;     data-btn=&quot;delete&quot;   &gt;     Delete   &lt;\/button&gt; &lt;\/li&gt; ` <\/code><\/pre>\n<p>  client\/List.js:<\/p>\n<pre><code class=\"javascript\">\/**  * \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Item  *  * \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447  *  * \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u044f\u0442\u0435\u043d \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b reduce  * https:\/\/developer.mozilla.org\/ru\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/Reduce *\/ import { Item } from &quot;.\/Item.js&quot;  export const List = (todos) =&gt; \/*html*\/ `   &lt;ul id=&quot;list&quot;&gt;     ${todos.reduce(       (html, todo) =&gt;         (html += `             ${Item(todo)}         `),       ''     )}   &lt;\/ul&gt; ` <\/code><\/pre>\n<p>  \u0421 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438.<\/p>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u0443 \u0441\u043a\u0440\u0438\u043f\u0442\u0443, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  src\/helpers.js:<\/p>\n<pre><code class=\"javascript\">\/**  * \u0434\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f  * \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043a\u043d\u043e\u043f\u043e\u043a  * \u0434\u043b\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u0447  *  * \u043e\u043d\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 - \u043d\u0430\u0436\u0430\u0442\u0443\u044e \u043a\u043d\u043e\u043f\u043a\u0443 \u0438 \u043a\u043b\u0430\u0441\u0441 - \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 checked  *  * \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 root,  * \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u043d\u0435\u043c\u0443 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e  * \u0438\u0437 \u043b\u044e\u0431\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u0434\u0430, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 *\/ export const toggleClass = (element, className) =&gt; {   root.querySelector(`.${className}`).classList.remove(className)    element.classList.add(className) }  \/\/ \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 export const todosExample = [   {     id: '1',     text: 'Learn HTML',     done: true   },   {     id: '2',     text: 'Learn CSS',     done: true   },   {     id: '3',     text: 'Learn JavaScript',     done: false   },   {     id: '4',     text: 'Stay Alive',     done: false   } ] <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 (\u043f\u043e\u043a\u0430 \u0432 \u0444\u043e\u0440\u043c\u0435 <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Window\/localStorage\" rel=\"nofollow\">\u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430<\/a>).<\/p>\n<p>  src\/storage.js:<\/p>\n<pre><code class=\"javascript\">\/**  * \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430  * get - \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0443\u0434\u0443\u0448\u0435\u043a  * set - \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 (\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f) \u0442\u0443\u0434\u0443\u0448\u0435\u043a *\/ export default (() =&gt; ({   get: () =&gt; JSON.parse(localStorage.getItem('todos')),   set: (todos) =&gt; { localStorage.setItem('todos', JSON.stringify(todos)) } }))() <\/code><\/pre>\n<p>  \u041f\u043e\u0431\u0430\u043b\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0438 \u0445\u0432\u0430\u0442\u0438\u0442. \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0434\u0435\u043b\u0443.<\/p>\n<p>  src\/script.js:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 import Form from '.\/components\/Form.js' import Buttons from '.\/components\/Buttons.js' import { List } from '.\/components\/List.js' import { Item } from '.\/components\/Item.js'  import { toggleClass, todosExample } from '.\/src\/helpers.js'  import storage from '.\/src\/storage.js'  \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447 const App = (root, todos) =&gt; {   \/\/ \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432   root.innerHTML = `     &lt;h1 id=&quot;title&quot;&gt;       JS Todos App     &lt;\/h1&gt;     ${Form}     &lt;h3 id=&quot;counter&quot;&gt;&lt;\/h3&gt;     ${Buttons}     ${List(todos)}   `    \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0441\u0447\u0435\u0442\u0447\u0438\u043a   updateCounter()    \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a   const $addBtn = root.querySelector('[data-btn=&quot;add&quot;]')    \/\/ \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f   \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a   function addTodo() {     if (!input.value.trim()) return      const todo = {       \/\/ \u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0435\u0433\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438       id: Date.now().toString(16).slice(-4).padStart(5, 'x'),       text: input.value,       done: false     }      list.insertAdjacentHTML('beforeend', Item(todo))      todos.push(todo)      \/\/ \u043e\u0447\u0438\u0449\u0430\u0435\u043c \u043f\u043e\u043b\u0435 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0444\u043e\u043a\u0443\u0441     clearInput()      updateCounter()   }    \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438   \/\/ \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 DOM-\u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441\u043f\u0438\u0441\u043a\u0430   function completeTodo(item) {     const todo = findTodo(item)      todo.done = !todo.done      \/\/ \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0432\u0448\u0438\u0439\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442     renderItem(item, todo)      updateCounter()   }    \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438   function updateTodo(item) {     item.classList.add('disabled')      const todo = findTodo(item)      const oldValue = todo.text      input.value = oldValue      \/\/ \u0442\u043e\u043d\u043a\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442: \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043e\u0434\u043d\u0443 \u0438 \u0442\u0443 \u0436\u0435 \u043a\u043d\u043e\u043f\u043a\u0443     \/\/ \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0438     $addBtn.textContent = 'Update'      \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0430\u0437\u043e\u0432\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a     $addBtn.addEventListener(       'click',       (e) =&gt; {         \/\/ \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0434\u043b\u044f \u0442\u043e\u0433\u043e,         \/\/ \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u043d\u0435 \u0432\u044b\u0437\u0432\u0430\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a         e.stopPropagation()          const newValue = input.value.trim()          if (newValue &amp;&amp; newValue !== oldValue) {           todo.text = newValue         }          renderItem(item, todo)          clearInput()          $addBtn.textContent = 'Add'       },       { once: true }     )   }    \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438   function deleteTodo(item) {     const todo = findTodo(item)      item.remove()      todos.splice(todos.indexOf(todo), 1)      updateCounter()   }    \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438   function findTodo(item) {     const { id } = item.dataset      const todo = todos.find((todo) =&gt; todo.id === id)      return todo   }    \/\/ \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b   \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u0434\u0430\u0447   \/\/ \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438   function filterTodos(value) {     const $items = [...root.querySelectorAll('.item')]      switch (value) {       \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438       case 'all':         $items.forEach((todo) =&gt; (todo.style.display = ''))         break       \/\/ \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438       case 'active':         \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0432\u0441\u0435 \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0435         filterTodos('all')         $items           .filter((todo) =&gt; todo.classList.contains('completed'))           .forEach((todo) =&gt; (todo.style.display = 'none'))         break       \/\/ \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438       case 'completed':         \/\/ \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0432\u0441\u0435 \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435         filterTodos('all')         $items           .filter((todo) =&gt; !todo.classList.contains('completed'))           .forEach((todo) =&gt; (todo.style.display = 'none'))         break     }   }    \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0430   function updateCounter() {     \/\/ \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447     const count = todos.filter((todo) =&gt; !todo.done).length      counter.textContent = `       ${count &gt; 0 ? `${count} todo(s) left` : 'All todos completed'}     `      if (!todos.length) {       counter.textContent = 'There are no todos'       buttons.style.display = 'none'     } else {       buttons.style.display = ''     }   }    \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0438\u0437\u043c\u0435\u043d\u0438\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430   function renderItem(item, todo) {     item.outerHTML = Item(todo)   }    \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0438\u043d\u043f\u0443\u0442\u0430   function clearInput() {     input.value = ''     input.focus()   }    \/\/ \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c\u0443 \u0443\u0437\u043b\u0443   root.onclick = ({ target }) =&gt; {     if (target.tagName !== 'BUTTON') return      const { btn } = target.dataset      if (target.classList.contains('filter')) {       filterTodos(btn)       toggleClass(target, 'checked')     }      const item = target.parentElement      switch (btn) {       case 'add':         addTodo()         break       case 'complete':         completeTodo(item)         break       case 'update':         updateTodo(item)         break       case 'delete':         deleteTodo(item)         break     }   }    \/\/ \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0435 Enter   document.onkeypress = ({ key }) =&gt; {     if (key === 'Enter') addTodo()   }    \/\/ \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435\u043c   window.onbeforeunload = () =&gt; {     storage.set(todos)   } }  \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f ;(() =&gt; {   \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430   let todos = storage.get('todos')    \/\/ \u0435\u0441\u043b\u0438 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043f\u0443\u0441\u0442\u043e   if (!todos || !todos.length) todos = todosExample    App(root, todos) })() <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430. \u0417\u0430\u0434\u0430\u0447\u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0443\u0433\u0440\u043e\u0436\u0430\u0435\u0442 (\u0432\u0440\u043e\u0434\u0435 \u0431\u044b).<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c: 1) \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u2014 \u043e\u043a\u043e\u043b\u043e 5 \u041c\u0431, \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430; 2) \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0442\u0435\u0440\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u043e\u0447\u0438\u0441\u0442\u043a\u0435 \u0438\u0441\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043a\u043d\u043e\u043f\u043a\u0438 Clear site data \u0432\u043a\u043b\u0430\u0434\u043a\u0438 Application Chrome DevTools \u0438 \u0442.\u0434.; 3) \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0430 \u043a \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0443 \u2014 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u0445.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 (\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430) \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/developer.mozilla.org\/ru\/docs\/Web\/API\/IndexedDB_API\" rel=\"nofollow\">IndexedDB<\/a>.<\/p>\n<p>  \u0418\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u043c\u0435\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0435\u0439 Jake Archibald <a href=\"https:\/\/github.com\/jakearchibald\/idb-keyval\" rel=\"nofollow\">idb-keyval<\/a>. \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c <a href=\"https:\/\/raw.githubusercontent.com\/jakearchibald\/idb-keyval\/master\/dist\/idb-keyval.mjs\" rel=\"nofollow\">\u044d\u0442\u043e\u0442 \u043a\u043e\u0434<\/a> \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u0444\u0430\u0439\u043b src\/idb.js.<\/p>\n<p>  \u0412\u043d\u043e\u0441\u0438\u043c \u0432 src\/script.js \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"javascript\">\/\/ import storage from '.\/src\/storage.js' import { get, set } from '.\/src\/idb.js'  window.onbeforeunload = () =&gt; {   \/\/ storage.set(todos)   set('todos', todos) }  \/\/ \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043b\u0430 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 ;(async () =&gt; {   \/\/ let todos = storage.get('todos')    let todos = await get('todos')    if (!todos || !todos.length) todos = todosExample    App(root, todos) })() <\/code><\/pre>\n<p>  \u0412\u0442\u043e\u0440\u0443\u044e \u0438 \u0442\u0440\u0435\u0442\u044c\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0430\u043a\u043e\u0432\u043e\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043b\u0430\u0447\u043d\u0443\u044e MongoDB. \u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430. \u0418\u0437 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0438 \u043a\u043e\u043d\u0444\u0438\u0434\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041e\u0434\u043d\u0430\u043a\u043e, \u043f\u0440\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u0438, \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043b\u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u043e\u0439 \u0432 \u0411\u0414.<\/p>\n<h6>React, Vue<\/h6>\n<p>  \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0442\u0443\u0434\u0443\u0448\u043a\u0438 \u043d\u0430 React \u0438 Vue.<\/p>\n<p>  React:<\/p>\n<div class=\"oembed\"><iframe id=\"5fe45db23b295d140fdb393d\" src=\"https:\/\/embedd.srv.habr.com\/iframe\/5fe45db23b295d140fdb393d\"><\/iframe><\/div>\n<p>  Vue:<\/p>\n<div class=\"oembed\"><iframe id=\"5fe45db2cb79a1e12d6664bf\" src=\"https:\/\/embedd.srv.habr.com\/iframe\/5fe45db2cb79a1e12d6664bf\"><\/iframe><\/div>\n<p>  <\/p>\n<h3>\u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440, \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0435\u043c \u0431\u043e\u043b\u0435\u0435, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439:<\/p>\n<ol>\n<li>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0430\u043a\u043a\u0430\u0443\u043d\u0442 \u0432 <a href=\"https:\/\/cloud.mongodb.com\/\" rel=\"nofollow\">MongoDB Atlas<\/a><\/li>\n<li>\u0412\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0435 Projects \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 New Project<\/li>\n<li>\u0412\u0432\u043e\u0434\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, todos-db, \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c Next<\/li>\n<li>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c Create Project<\/li>\n<li>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c Build a Cluster<\/li>\n<li>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c Create a cluster (FREE)<\/li>\n<li>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430 \u0438 \u0440\u0435\u0433\u0438\u043e\u043d, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Azure \u0438 Hong Kong, \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c Create Cluster<\/li>\n<li>\u0416\u0434\u0435\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c connect<\/li>\n<li>\u0412 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 Add a connection IP address \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043b\u0438\u0431\u043e Add Your Current IP Address, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 IP, \u043b\u0438\u0431\u043e Allow Access from Anywhere, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441, \u043a\u0430\u043a \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 IP (\u0435\u0441\u043b\u0438 \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u0435\u0442\u0435\u0441\u044c, \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442)<\/li>\n<li>\u0412\u0432\u043e\u0434\u0438\u043c \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0430\u0440\u043e\u043b\u044c, \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c Create Database User, \u0437\u0430\u0442\u0435\u043c \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c Choose a connection method<\/li>\n<li>\u0412\u044b\u0431\u0438\u0440\u0430\u0435\u043c Connect your application<\/li>\n<li>\u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u0438\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0430 Add your connection string into your application code<\/li>\n<li>\u041d\u0430\u0436\u0438\u043c\u0430\u0435\u043c Close<\/li>\n<\/ol>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/rg\/p6\/mg\/rgp6mg93mjgs58ry7krffru2_nq.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/v_\/kn\/2h\/v_kn2hkkonkoiltuigwhmocpgds.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/qt\/pa\/ja\/qtpajasnm1rhm5glqxhsegdbmxi.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/lq\/hg\/i4\/lqhgi4bxzubt_3otxsokec8nmqs.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/oa\/br\/wd\/oabrwdbbfxgk5nme07h0v5do7pk.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ms\/ca\/0w\/msca0wpfwlkkfo0fsnxv2zxe0su.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/51\/5m\/hl\/515mhl7ioqxc6awb1k9cjjq5lp4.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/sf\/0u\/2h\/sf0u2hbog4wkyuapoxphlclyloe.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/v7\/om\/py\/v7ompytuxthndokiqsdbtcf23ho.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xr\/2x\/jg\/xr2xjgghvr0i6ecoafufuz_cwdu.png\"><\/p>\n<p>  \u0412 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b .env \u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 (\u043c\u0435\u043d\u044f\u0435\u043c &lt;username&gt;, &lt;password&gt; \u0438 &lt;dbname&gt; \u043d\u0430 \u0441\u0432\u043e\u0438 \u0434\u0430\u043d\u043d\u044b\u0435):<\/p>\n<pre><code class=\"javascript\">MONGO_URI=mongodb+srv:\/\/&lt;username&gt;:&lt;password&gt;@cluster0.hfvcf.mongodb.net\/&lt;dbname&gt;?retryWrites=true&amp;w=majority <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0421\u0435\u0440\u0432\u0435\u0440<\/h3>\n<p>  \u041d\u0430\u0445\u043e\u0434\u044f\u0441\u044c \u0432 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<pre><code class=\"javascript\">npm init -y \/\/ \u0438\u043b\u0438 yarn init -yp <\/code><\/pre>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"javascript\">yarn add cors dotenv express express-validator mongoose <\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/cors\" rel=\"nofollow\">cors<\/a> \u2014 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0443 \u043e\u0431\u0449\u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f (\u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430)<\/li>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/dotenv\" rel=\"nofollow\">dotenv<\/a> \u2014 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c \u0441\u0440\u0435\u0434\u044b \u0432 \u0444\u0430\u0439\u043b\u0435 .env<\/li>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/express\" rel=\"nofollow\">express<\/a> \u2014 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 Node.js<\/li>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/express-validator\" rel=\"nofollow\">express-validator<\/a> \u2014 \u0441\u043b\u0443\u0436\u0438\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 (\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438) \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/mongoose\" rel=\"nofollow\">mongoose<\/a> \u2014 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 MongoDB<\/li>\n<\/ul>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438:<\/p>\n<pre><code class=\"javascript\">yarn add -D nodemon open-cli morgan <\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/nodemon\" rel=\"nofollow\">nodemon<\/a> \u2014 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0435\u0433\u043e \u043f\u0440\u0438 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0444\u0430\u0439\u043b<\/li>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/open-cli\" rel=\"nofollow\">open-cli<\/a> \u2014 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0441\u0435\u0440\u0432\u0435\u0440<\/li>\n<li><a href=\"https:\/\/www.npmjs.com\/package\/morgan\" rel=\"nofollow\">morgan<\/a> \u2014 \u043b\u043e\u0433\u0433\u0435\u0440 HTTP-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/li>\n<\/ul>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 package.json \u0441\u043a\u0440\u0438\u043f\u0442\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 (dev \u2014 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438 start \u2014 \u0434\u043b\u044f \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u043d-\u0441\u0435\u0440\u0432\u0435\u0440\u0430):<\/p>\n<pre><code class=\"javascript\">&quot;scripts&quot;: {   &quot;start&quot;: &quot;node index.js&quot;,   &quot;dev&quot;: &quot;open-cli http:\/\/localhost:1234 &amp;&amp; nodemon index.js&quot; }, <\/code><\/pre>\n<p>  \u041e\u0442\u043b\u0438\u0447\u043d\u043e. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b index.js \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u044f:<\/p>\n<pre><code class=\"javascript\">\/\/ \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 const express = require('express') const mongoose = require('mongoose') const cors = require('cors') const morgan = require('morgan')  require('dotenv\/config')  \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u043e\u0443\u0442\u0435\u0440 const app = express() const router = require('.\/server\/router')  \/\/ \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u043e\u0435 \u041f\u041e app.use(express.json()) app.use(express.urlencoded({ extended: false })) app.use(cors()) app.use(morgan('dev'))  \/\/ \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0433\u0434\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b app.use(express.static(__dirname))  \/\/ \u043f\u043e\u0434\u043b\u044e\u0447\u0430\u0435\u043c\u0441\u044f \u043a \u0411\u0414 mongoose.connect(   process.env.MONGO_URI,   {     useNewUrlParser: true,     useUnifiedTopology: true,     useFindAndModify: false,     useCreateIndex: true   },   () =&gt; console.log('Connected to database') )  \/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c index.html \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u043c\u0443 \u0443\u0437\u043b\u0443 app.get('\/', (_, res) =&gt; {   res.sendFile(__dirname + '\/index.html') })  \/\/ \u043f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043a api \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u043e\u0443\u0442\u0435\u0440\u0443 app.use('\/api', router)  \/\/ \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u043f\u043e\u0440\u0442 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440 const PORT = process.env.PORT || 1234 app.listen(PORT, () =&gt; console.log(`Server is running`)) <\/code><\/pre>\n<p>  \u0422\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0435\u0440:<\/p>\n<pre><code class=\"javascript\">yarn dev \/\/ \u0438\u043b\u0438 npm run dev <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ka\/s8\/mq\/kas8mqhnmbisaopthb-qxtgwgmc.png\"><\/p>\n<p>  \u041f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u043e, \u0441\u0435\u0440\u0432\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u0435\u0439. \u041d\u043e \u043f\u0435\u0440\u0435\u0434 \u044d\u0442\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0441\u0445\u0435\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e server \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u00ab\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445\u00bb \u0444\u0430\u0439\u043b\u043e\u0432. \u0412 \u044d\u0442\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b\u044b Todo.js \u0438 router.js.<\/p>\n<p>  \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435:<\/p>\n<pre><code class=\"javascript\">client   components     Buttons.js     Form.js     Item.js     List.js   src     helpers.js     idb.js     storage.js   script.js   style.css server   Todo.js   router.js .env index.html index.js package.json yarn.lock (\u043b\u0438\u0431\u043e package-lock.json) <\/code><\/pre>\n<p>  \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u0445\u0435\u043c\u0443 \u0432 src\/Todo.js:<\/p>\n<pre><code class=\"javascript\">const { Schema, model } = require('mongoose')  const todoSchema = new Schema({   id: {     type: String,     required: true,     unique: true   },   text: {     type: String,     required: true   },   done: {     type: Boolean,     required: true   } })  \/\/ \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u043c\u043e\u0434\u0435\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 module.exports = model('Todo', todoSchema) <\/code><\/pre>\n<p>  \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0430\u0446\u0438\u044e \u0432 src\/router.js:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0440\u043e\u0443\u0442\u0435\u0440 const router = require('express').Router() \/\/ \u043c\u043e\u0434\u0435\u043b\u044c \u0434\u0430\u043d\u043d\u044b\u0445 const Todo = require('.\/Todo') \/\/ \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 const { body, validationResult } = require('express-validator')  \/**  * \u043d\u0430\u0448 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 (http:\/\/localhost:1234\/api)  * \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c 4 \u0437\u0430\u043f\u0440\u043e\u0441\u0430  * GET-\u0437\u0430\u043f\u0440\u043e\u0441 \/get - \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438\u0437 \u0411\u0414  * POST \/add - \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0411\u0414 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438  * DELETE \/delete\/:id - \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c  * PUT \/update - \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u043b\u0438 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438  *  * \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0411\u0414 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c Todo \u0438 \u043c\u0435\u0442\u043e\u0434\u044b  * find() - \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u0447  * save() - \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438  * deleteOne() - \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438  * updateOne() - \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438  *  * \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 - \u043e\u0431\u044a\u0435\u043a\u0442, \u0432 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0435 message \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e  * \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043b\u0438\u0431\u043e \u043e\u0431 \u0443\u0441\u043f\u0435\u0445\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043b\u0438\u0431\u043e \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 *\/  \/\/ \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u0447 router.get('\/get', async (_, res) =&gt; {   const todos = (await Todo.find()) || []   return res.json(todos) })  \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 router.post(   '\/add',   \/\/ \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438   [     body('id').exists(),     body('text').notEmpty().trim().escape(),     body('done').toBoolean()   ],   async (req, res) =&gt; {     \/\/ \u043e\u0448\u0438\u0431\u043a\u0438 - \u044d\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438     const errors = validationResult(req)      if (!errors.isEmpty()) {       return res.status(400).json({ message: errors.array()[0].msg })     }      const { id, text, done } = req.body      const todo = new Todo({       id,       text,       done     })      try {       await todo.save()       return res.status(201).json({ message: 'Todo created' })     } catch (error) {       return res.status(500).json({ message: `Error: ${error}` })     }   } )  \/\/ \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 router.delete('\/delete\/:id', async (req, res) =&gt; {   try {     await Todo.deleteOne({       id: req.params.id     })     res.status(201).json({ message: 'Todo deleted' })   } catch (error) {     return res.status(500).json({ message: `Error: ${error}` })   } })  \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 router.put(   '\/update',   [     body('text').notEmpty().trim().escape(),     body('done').toBoolean()   ],   async (req, res) =&gt; {     const errors = validationResult(req)      if (!errors.isEmpty()) {       return res.status(400).json({ message: errors.array()[0].msg })     }      const { id, text, done } = req.body      try {       await Todo.updateOne(         {           id         },         {           text,           done         }       )       return res.status(201).json({ message: 'Todo updated' })     } catch (error) {       return res.status(500).json({ message: `Error: ${error}` })     } })  \/\/ \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u0440\u043e\u0443\u0442\u0435\u0440\u0430 module.exports = router <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0418\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f<\/h3>\n<p>  \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0430\u0431\u0441\u0442\u0440\u0430\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u0431\u0435\u0433\u043d\u0435\u043c \u043a \u043f\u043e\u043c\u043e\u0449\u0438 \u0440\u043e\u0443\u0442\u0435\u0440\u0430. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b client\/src\/router.js:<\/p>\n<pre><code class=\"javascript\">\/**  * \u043d\u0430\u0448 \u0440\u043e\u0443\u0442\u0435\u0440 - \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f,  * \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0430\u044f \u0430\u0434\u0440\u0435\u0441 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 (url)  *  * \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438:  * get() - \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438\u0437 \u0411\u0414  * set() - \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0411\u0414 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438  * update() - \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0430 \u0438\u043b\u0438 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438  * delete() - \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c  *  * \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u0440\u043e\u043c\u0435 get(), \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0443  *  * \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 json  * (\u043e\u0431\u044a\u0435\u043a\u0442 \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c message) *\/  export const Router = (url) =&gt; ({   \/\/ \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0437\u0430\u0434\u0430\u0447   get: async () =&gt; {     const response = await fetch(`${url}\/get`)     return response.json()   },    \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438   set: async (todo) =&gt; {     const response = await fetch(`${url}\/add`, {       method: 'POST',       headers: {         'Content-Type': 'application\/json'       },       body: JSON.stringify(todo)     })      return response.json()   },    \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438   update: async (todo) =&gt; {     const response = await fetch(`${url}\/update`, {       method: 'PUT',       headers: {         'Content-Type': 'application\/json'       },       body: JSON.stringify(todo)     })      return response.json()   },    \/\/ \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438   delete: async ({ id }) =&gt; {     const response = await fetch(`${url}\/delete\/${id}`, {       method: 'DELETE'     })      return response.json()   } }) <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f CRUD-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 (create, read, update, delete \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435, \u0447\u0442\u0435\u043d\u0438\u0435, \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435, \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435), \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 src\/helpers.js \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043c\u043e\u0434\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c \u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \/\/ \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0435\u0433\u043e \u0447\u0435\u0440\u0435\u0437 \u0434\u0432\u0435 \u0441\u0435\u043a\u0443\u043d\u0434\u044b export const createModal = ({ message }) =&gt; {   root.innerHTML += `&lt;div data-id=&quot;modal&quot;&gt;${message}&lt;\/div&gt;`    const timer = setTimeout(() =&gt; {     root.querySelector('[data-id=&quot;modal&quot;]').remove()     clearTimeout(timer)   }, 2000) } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 client\/script.js:<\/p>\n<pre><code class=\"javascript\">import Form from '.\/components\/Form.js' import Buttons from '.\/components\/Buttons.js' import { List } from '.\/components\/List.js' import { Item } from '.\/components\/Item.js'  import { toggleClass, createModal, todosExample } from '.\/src\/helpers.js'  \/\/ \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0440\u043e\u0443\u0442\u0435\u0440 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0435\u043c\u0443 \u0430\u0434\u0440\u0435\u0441 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 import { Router } from '.\/src\/router.js' const router = Router('http:\/\/localhost:1234\/api')  const App = (root, todos) =&gt; {   root.innerHTML = `     &lt;h1 id=&quot;title&quot;&gt;       JS Todos App     &lt;\/h1&gt;     ${Form}     &lt;h3 id=&quot;counter&quot;&gt;&lt;\/h3&gt;     ${Buttons}     ${List(todos)}   `    updateCounter()    const $addBtn = root.querySelector('[data-btn=&quot;add&quot;]')    \/\/ \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b   async function addTodo() {     if (!input.value.trim()) return      const todo = {       id: Date.now().toString(16).slice(-4).padStart(5, 'x'),       text: input.value,       done: false     }      list.insertAdjacentHTML('beforeend', Item(todo))      todos.push(todo)      \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0411\u0414 \u043d\u043e\u0432\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u043c \u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e     createModal(await router.set(todo))      clearInput()      updateCounter()   }    async function completeTodo(item) {     const todo = findTodo(item)      todo.done = !todo.done      renderItem(item, todo)      \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438     createModal(await router.update(todo))      updateCounter()   }    function updateTodo(item) {     item.classList.add('disabled')      const todo = findTodo(item)      const oldValue = todo.text      input.value = oldValue      $addBtn.textContent = 'Update'      $addBtn.addEventListener(       'click',       async (e) =&gt; {         e.stopPropagation()          const newValue = input.value.trim()          if (newValue &amp;&amp; newValue !== oldValue) {           todo.text = newValue         }          renderItem(item, todo)          \/\/ \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u0434\u0430\u0447\u0438         createModal(await router.update(todo))          clearInput()          $addBtn.textContent = 'Add'       },       { once: true }     )   }    async function deleteTodo(item) {     const todo = findTodo(item)      item.remove()      todos.splice(todos.indexOf(todo), 1)      \/\/ \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443     createModal(await router.delete(todo))      updateCounter()   }    function findTodo(item) {     const { id } = item.dataset      const todo = todos.find((todo) =&gt; todo.id === id)      return todo   }    \/\/ \u0434\u0430\u043b\u044c\u0448\u0435 \u0432\u0441\u0435 \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435   \/\/ \u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c window.onbeforeunload   function filterTodos(value) {     const $items = [...root.querySelectorAll('.item')]      switch (value) {       case 'all':         $items.forEach((todo) =&gt; (todo.style.display = ''))         break       case 'active':         filterTodos('all')         $items           .filter((todo) =&gt; todo.classList.contains('completed'))           .forEach((todo) =&gt; (todo.style.display = 'none'))         break       case 'completed':         filterTodos('all')         $items           .filter((todo) =&gt; !todo.classList.contains('completed'))           .forEach((todo) =&gt; (todo.style.display = 'none'))         break     }   }    function updateCounter() {     const count = todos.filter((todo) =&gt; !todo.done).length      counter.textContent = `       ${count &gt; 0 ? `${count} todo(s) left` : 'All todos completed'}     `      if (!todos.length) {       counter.textContent = 'There are no todos'       buttons.style.display = 'none'     } else {       buttons.style.display = ''     }   }    function renderItem(item, todo) {     item.outerHTML = Item(todo)   }    function clearInput() {     input.value = ''     input.focus()   }    root.onclick = ({ target }) =&gt; {     if (target.tagName !== 'BUTTON') return      const { btn } = target.dataset      if (target.classList.contains('filter')) {       filterTodos(btn)       toggleClass(target, 'checked')     }      const item = target.parentElement      switch (btn) {       case 'add':         addTodo()         break       case 'complete':         completeTodo(item)         break       case 'update':         updateTodo(item)         break       case 'delete':         deleteTodo(item)         break     }   }    document.onkeypress = ({ key }) =&gt; {     if (key === 'Enter') addTodo()   } }  ;(async () =&gt; {   \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0437 \u0411\u0414   let todos = await router.get()    if (!todos || !todos.length) todos = todosExample    App(root, todos) })() <\/code><\/pre>\n<p>  \u041f\u043e\u0437\u0434\u0440\u0430\u0432\u043b\u044f\u044e, \u0432\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043b\u043b\u0441\u0442\u0435\u043a-\u0442\u0443\u0434\u0443\u0448\u043a\u0443.<\/p>\n<h6>TypeScript<\/h6>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0430\u0431\u043e\u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u044f\u0437\u044b\u043a \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043d\u0435 \u043a\u043e\u043c\u0438\u043b\u044c\u0444\u043e, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u043d\u0430 <a href=\"https:\/\/github.com\/harryheman\/FullStack-Todos-App\/tree\/main\/react-typecript-express-mongoose\" rel=\"nofollow\">\u044d\u0442\u043e\u0442 \u043a\u043e\u0434<\/a>. \u0422\u0430\u043c \u0432\u044b \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0444\u0443\u043b\u043b\u0441\u0442\u0435\u043a-\u0442\u0443\u0434\u0443\u0448\u043a\u0443 \u043d\u0430 React \u0438 TypeScript.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/jr\/en\/wh\/jrenwhgghxnnmo-zix06kyfbkdo.png\"><\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u041f\u043e\u0434\u0432\u0435\u0434\u0435\u043c \u043a\u0440\u0430\u0442\u043a\u0438\u0435 \u0438\u0442\u043e\u0433\u0438.<\/p>\n<p>  \u041c\u044b \u0441 \u0432\u0430\u043c\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0435 \u043a\u043b\u0438\u0435\u043d\u0442-\u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430, \u0438\u043d\u0442\u0435\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0441 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0439 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445. \u041d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0441\u0430\u043c\u044b\u0439 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 (\u0447\u0438\u0441\u0442\u044b\u0439) JavaScript, \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u2014 Node.js \u0441\u043a\u0432\u043e\u0437\u044c \u043f\u0440\u0438\u0437\u043c\u0443 Express.js, \u0434\u043b\u044f \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u0411\u0414 \u2014 Mongoose. \u041c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043f\u0430\u0440\u043e\u0447\u043a\u0443 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 (local storage, indexeddb \u2014 idb-keyval). \u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0435\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043d\u0430 React (+TypeScript) \u0438 Vue. \u041f\u043e-\u043c\u043e\u0435\u043c\u0443, \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>  \u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u043b\u044e\u0431\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 \u0445\u043e\u0440\u043e\u0448\u0435\u0433\u043e \u0434\u043d\u044f.<\/p><\/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\/post\/534622\/\"> https:\/\/habr.com\/ru\/post\/534622\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ig\/mq\/2d\/igmq2dvqrh3pvqpohaicef0c3zi.png\"><\/p>\n<p>  \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a, \u0434\u0440\u0443\u0437\u044c\u044f!<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0443\u043b\u043b\u0441\u0442\u0435\u043a-\u0442\u0443\u0434\u0443\u0448\u043a\u0443.<\/p>\n<p>  \u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b:<\/p>\n<ul>\n<li>\u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0441\u043f\u0438\u0441\u043e\u043a<\/li>\n<li>\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438<\/li>\n<li>\u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/li>\n<li>\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430<\/li>\n<li>\u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u0437\u0430\u0434\u0430\u0447: \u0432\u0441\u0435, \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435, \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0435<\/li>\n<li>\u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/li>\n<\/ul>\n<p>  \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/nd\/st\/7k\/ndst7klmkvjcdjvlam_ewm9ylaa.png\"><br \/>  \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u043e\u0445\u0432\u0430\u0442\u0430 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c JavaScript, \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u2014 \u043d\u0430 Node.js. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043d\u043e\u0434\u044b \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d Express.js, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u2014 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (Local Storage), \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 (IndexedDB) \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043e\u0431\u043b\u0430\u0447\u043d\u0430\u044f MongoDB.<\/p>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u043b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0435 \u0442\u0430\u043a\u0438\u043c\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430\u043c\u0438, \u043a\u0430\u043a React \u0438 Vue: \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u043d\u0430 \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435\u0445 \u0447\u0430\u0441\u0442\u0435\u0439 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u043b\u0438\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c \u0438 \u0442.\u0434. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u0432\u043e\u0437\u0434\u0435\u0440\u0436\u0438\u043c\u0441\u044f \u043e\u0442 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u044f HTML, CSS \u0438 JavaScript.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-315489","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/315489","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=315489"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/315489\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=315489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=315489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=315489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}