{"action":"created","comment":{"url":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/comments/35246554","id":35246554,"diff_hunk":"@@ -0,0 +1,224 @@\n+# Использование ПромисПайпов на примере авторизации пользователя\n+\n+Простой пример использования ПромисПайпов для решения задачи авторизации пользователя.\n+Вы можете запустить пример набрав в консоли находясь в директорие с примером:\n+\n+    npm install\n+    npm start\n+\n+И открыв в браузере:\n+\n+    http://localhost:3000/\n+\n+Если же вы хотите разобрать все по косточкам, то именно это мы и сделаем далее.\n+Сама задача состоит из трех частей:\n+\n+1. На стороне клиента получить логин и пароль при отправке формы.\n+2. На стороне сервера проверить логин и пароль.\n+3. На стороне клиента сообщить пользователю о результате проверки.\n+\n+Сам проект будет состоять из трех файлов:\n+\n+1. `index.html` — статическая html-страничка, которая содержит форму ввода логина и пароля и подключает скрипт `client.js`.\n+2. `backend.js` — сервер, который отдает статику и инициирует ПромисПайп на стороне сервера.\n+3. `frontend.js` — скрипт, который инициирует ПромисПайп на стороне клиента и передаст в него данные после отправки формы.\n+4. `common.js` — скрипт, общий для клиента и сервера и представляющий собой логику работы пайпа.\n+\n+Пример имеет следующие зависимости:\n+\n+* express — фреймворк с помощью которого реализован сервер\n+* body-parser — парсит тело запроса на предмет переменных\n+* promise-pipe — непосредственно ПромисПайпы\n+* es6-promise — Промисы es6\n+* browserify — он нужен что бы собрать для использования в браузере `client.js`\n+\n+Что бы не устанавливать их все отдельно клонируйте в директории с примером запустите `npm install`.\n+\n+\n+## index.html\n+\n+Это просто статическая страничка.\n+Она содержит в себе форму, которая позволяет отправить :\n+\n+    <form action=\"/login/\" method=\"post\" class=\"login-form\">\n+      <input type=\"text\" name=\"login\" placeholder=\"Логин : Carmack\" required=\"required\">\n+      <input type=\"password\" name=\"password\" placeholder=\"Пароль : iddqd\" required=\"required\">\n+      <button type=\"submit\">Вход</button>\n+      <p class=\"message message_fail\">Вы ошиблись при вводе логина или пароля.</p>\n+      <p class=\"message message_success\">Добро пожаловать!</p>\n+    </form>\n+\n+И, кроме того, подключает в конце `body` скрипт `frontend.js` (после сборки browserify).\n+\n+  <script src=\"bundle.js\"></script>\n+\n+\n+## backend.js\n+\n+Для начала просто настроим сервер.\n+\n+    /* Мы используем фреймфорк express.js для реализации сервера */\n+    var express = require('express')\n+        , app = express()\n+        , bodyParser = require('body-parser')\n+        , server = require('http').Server(app);\n+\n+    /* Ожидается что промиспайпы получат уже распаршенные данные */\n+    app.use(bodyParser.urlencoded({ extended: false }));\n+    app.use(bodyParser.json());\n+\n+    /* Раздача статики, что бы мы могли получить доступ к index.html */\n+    app.use(express.static(\"./\"));\n+    /* Запускаем сервер */\n+    server.listen(3000);\n+\n+Запускать его можно, как и любой скрипт, в консоли коммандой:\n+\n+    node backend.js\n+\n+После этого открыв ссылку [http://localhost:3000/][1] вы должны увидеть index.html\n+Теперь добавим до `server.listen(3000);` инициализацию ПромисПайпов.\n+\n+    /* Добавляем скрипт, общий для бекенда и фронтенда */\n+    var pipe = require('./common.js')\n+        /* Подключаем скрипт коннектора промиспайпов */\n+        , connectors = require('./node_modules/promise-pipe/example/connectors/HTTPDuplexStream')\n+        /* Получаем экземпляр промиспайпа, созданный в этом скрипте */\n+        , PromisePipe = pipe.PromisePipe\n+    /* Указыаем какой транспорт используется */","path":"example/login/README.md","position":88,"original_position":88,"commit_id":"038b616ca5e7f6c8ed50c6b282ed22a263b3923f","original_commit_id":"038b616ca5e7f6c8ed50c6b282ed22a263b3923f","user":{"login":"edjafarov","id":509978,"avatar_url":"https://avatars.githubusercontent.com/u/509978?v=3","gravatar_id":"","url":"https://api.github.com/users/edjafarov","html_url":"https://github.com/edjafarov","followers_url":"https://api.github.com/users/edjafarov/followers","following_url":"https://api.github.com/users/edjafarov/following{/other_user}","gists_url":"https://api.github.com/users/edjafarov/gists{/gist_id}","starred_url":"https://api.github.com/users/edjafarov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edjafarov/subscriptions","organizations_url":"https://api.github.com/users/edjafarov/orgs","repos_url":"https://api.github.com/users/edjafarov/repos","events_url":"https://api.github.com/users/edjafarov/events{/privacy}","received_events_url":"https://api.github.com/users/edjafarov/received_events","type":"User","site_admin":false},"body":"/* Указыаем какой транспорт используется при переходе с сервера на клиент */","created_at":"2015-07-22T18:28:19Z","updated_at":"2015-07-22T18:28:19Z","html_url":"https://github.com/edjafarov/PromisePipe/pull/29#discussion_r35246554","pull_request_url":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/comments/35246554"},"html":{"href":"https://github.com/edjafarov/PromisePipe/pull/29#discussion_r35246554"},"pull_request":{"href":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/29","id":40595978,"html_url":"https://github.com/edjafarov/PromisePipe/pull/29","diff_url":"https://github.com/edjafarov/PromisePipe/pull/29.diff","patch_url":"https://github.com/edjafarov/PromisePipe/pull/29.patch","issue_url":"https://api.github.com/repos/edjafarov/PromisePipe/issues/29","number":29,"state":"open","locked":false,"title":"simple login example","user":{"login":"edjafarov","id":509978,"avatar_url":"https://avatars.githubusercontent.com/u/509978?v=3","gravatar_id":"","url":"https://api.github.com/users/edjafarov","html_url":"https://github.com/edjafarov","followers_url":"https://api.github.com/users/edjafarov/followers","following_url":"https://api.github.com/users/edjafarov/following{/other_user}","gists_url":"https://api.github.com/users/edjafarov/gists{/gist_id}","starred_url":"https://api.github.com/users/edjafarov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edjafarov/subscriptions","organizations_url":"https://api.github.com/users/edjafarov/orgs","repos_url":"https://api.github.com/users/edjafarov/repos","events_url":"https://api.github.com/users/edjafarov/events{/privacy}","received_events_url":"https://api.github.com/users/edjafarov/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-22T18:27:13Z","updated_at":"2015-07-22T18:28:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fa2c9e0629f382e244e17f263341b5fee4eaff22","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/29/commits","review_comments_url":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/29/comments","review_comment_url":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edjafarov/PromisePipe/issues/29/comments","statuses_url":"https://api.github.com/repos/edjafarov/PromisePipe/statuses/038b616ca5e7f6c8ed50c6b282ed22a263b3923f","head":{"label":"SilentImp:master","ref":"master","sha":"038b616ca5e7f6c8ed50c6b282ed22a263b3923f","user":{"login":"SilentImp","id":217308,"avatar_url":"https://avatars.githubusercontent.com/u/217308?v=3","gravatar_id":"","url":"https://api.github.com/users/SilentImp","html_url":"https://github.com/SilentImp","followers_url":"https://api.github.com/users/SilentImp/followers","following_url":"https://api.github.com/users/SilentImp/following{/other_user}","gists_url":"https://api.github.com/users/SilentImp/gists{/gist_id}","starred_url":"https://api.github.com/users/SilentImp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilentImp/subscriptions","organizations_url":"https://api.github.com/users/SilentImp/orgs","repos_url":"https://api.github.com/users/SilentImp/repos","events_url":"https://api.github.com/users/SilentImp/events{/privacy}","received_events_url":"https://api.github.com/users/SilentImp/received_events","type":"User","site_admin":false},"repo":{"id":39521978,"name":"PromisePipe","full_name":"SilentImp/PromisePipe","owner":{"login":"SilentImp","id":217308,"avatar_url":"https://avatars.githubusercontent.com/u/217308?v=3","gravatar_id":"","url":"https://api.github.com/users/SilentImp","html_url":"https://github.com/SilentImp","followers_url":"https://api.github.com/users/SilentImp/followers","following_url":"https://api.github.com/users/SilentImp/following{/other_user}","gists_url":"https://api.github.com/users/SilentImp/gists{/gist_id}","starred_url":"https://api.github.com/users/SilentImp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilentImp/subscriptions","organizations_url":"https://api.github.com/users/SilentImp/orgs","repos_url":"https://api.github.com/users/SilentImp/repos","events_url":"https://api.github.com/users/SilentImp/events{/privacy}","received_events_url":"https://api.github.com/users/SilentImp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SilentImp/PromisePipe","description":"PromisePipe - reusable cross process promise chains","fork":true,"url":"https://api.github.com/repos/SilentImp/PromisePipe","forks_url":"https://api.github.com/repos/SilentImp/PromisePipe/forks","keys_url":"https://api.github.com/repos/SilentImp/PromisePipe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SilentImp/PromisePipe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SilentImp/PromisePipe/teams","hooks_url":"https://api.github.com/repos/SilentImp/PromisePipe/hooks","issue_events_url":"https://api.github.com/repos/SilentImp/PromisePipe/issues/events{/number}","events_url":"https://api.github.com/repos/SilentImp/PromisePipe/events","assignees_url":"https://api.github.com/repos/SilentImp/PromisePipe/assignees{/user}","branches_url":"https://api.github.com/repos/SilentImp/PromisePipe/branches{/branch}","tags_url":"https://api.github.com/repos/SilentImp/PromisePipe/tags","blobs_url":"https://api.github.com/repos/SilentImp/PromisePipe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SilentImp/PromisePipe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SilentImp/PromisePipe/git/refs{/sha}","trees_url":"https://api.github.com/repos/SilentImp/PromisePipe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SilentImp/PromisePipe/statuses/{sha}","languages_url":"https://api.github.com/repos/SilentImp/PromisePipe/languages","stargazers_url":"https://api.github.com/repos/SilentImp/PromisePipe/stargazers","contributors_url":"https://api.github.com/repos/SilentImp/PromisePipe/contributors","subscribers_url":"https://api.github.com/repos/SilentImp/PromisePipe/subscribers","subscription_url":"https://api.github.com/repos/SilentImp/PromisePipe/subscription","commits_url":"https://api.github.com/repos/SilentImp/PromisePipe/commits{/sha}","git_commits_url":"https://api.github.com/repos/SilentImp/PromisePipe/git/commits{/sha}","comments_url":"https://api.github.com/repos/SilentImp/PromisePipe/comments{/number}","issue_comment_url":"https://api.github.com/repos/SilentImp/PromisePipe/issues/comments{/number}","contents_url":"https://api.github.com/repos/SilentImp/PromisePipe/contents/{+path}","compare_url":"https://api.github.com/repos/SilentImp/PromisePipe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SilentImp/PromisePipe/merges","archive_url":"https://api.github.com/repos/SilentImp/PromisePipe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SilentImp/PromisePipe/downloads","issues_url":"https://api.github.com/repos/SilentImp/PromisePipe/issues{/number}","pulls_url":"https://api.github.com/repos/SilentImp/PromisePipe/pulls{/number}","milestones_url":"https://api.github.com/repos/SilentImp/PromisePipe/milestones{/number}","notifications_url":"https://api.github.com/repos/SilentImp/PromisePipe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SilentImp/PromisePipe/labels{/name}","releases_url":"https://api.github.com/repos/SilentImp/PromisePipe/releases{/id}","created_at":"2015-07-22T18:04:13Z","updated_at":"2015-07-22T18:04:14Z","pushed_at":"2015-07-22T18:08:58Z","git_url":"git://github.com/SilentImp/PromisePipe.git","ssh_url":"git@github.com:SilentImp/PromisePipe.git","clone_url":"https://github.com/SilentImp/PromisePipe.git","svn_url":"https://github.com/SilentImp/PromisePipe","homepage":"","size":557,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"edjafarov:master","ref":"master","sha":"e3d91744c7e204366ffc8948ba12432e407a0f46","user":{"login":"edjafarov","id":509978,"avatar_url":"https://avatars.githubusercontent.com/u/509978?v=3","gravatar_id":"","url":"https://api.github.com/users/edjafarov","html_url":"https://github.com/edjafarov","followers_url":"https://api.github.com/users/edjafarov/followers","following_url":"https://api.github.com/users/edjafarov/following{/other_user}","gists_url":"https://api.github.com/users/edjafarov/gists{/gist_id}","starred_url":"https://api.github.com/users/edjafarov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edjafarov/subscriptions","organizations_url":"https://api.github.com/users/edjafarov/orgs","repos_url":"https://api.github.com/users/edjafarov/repos","events_url":"https://api.github.com/users/edjafarov/events{/privacy}","received_events_url":"https://api.github.com/users/edjafarov/received_events","type":"User","site_admin":false},"repo":{"id":29875225,"name":"PromisePipe","full_name":"edjafarov/PromisePipe","owner":{"login":"edjafarov","id":509978,"avatar_url":"https://avatars.githubusercontent.com/u/509978?v=3","gravatar_id":"","url":"https://api.github.com/users/edjafarov","html_url":"https://github.com/edjafarov","followers_url":"https://api.github.com/users/edjafarov/followers","following_url":"https://api.github.com/users/edjafarov/following{/other_user}","gists_url":"https://api.github.com/users/edjafarov/gists{/gist_id}","starred_url":"https://api.github.com/users/edjafarov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edjafarov/subscriptions","organizations_url":"https://api.github.com/users/edjafarov/orgs","repos_url":"https://api.github.com/users/edjafarov/repos","events_url":"https://api.github.com/users/edjafarov/events{/privacy}","received_events_url":"https://api.github.com/users/edjafarov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/edjafarov/PromisePipe","description":"PromisePipe - reusable cross process promise chains","fork":false,"url":"https://api.github.com/repos/edjafarov/PromisePipe","forks_url":"https://api.github.com/repos/edjafarov/PromisePipe/forks","keys_url":"https://api.github.com/repos/edjafarov/PromisePipe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edjafarov/PromisePipe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edjafarov/PromisePipe/teams","hooks_url":"https://api.github.com/repos/edjafarov/PromisePipe/hooks","issue_events_url":"https://api.github.com/repos/edjafarov/PromisePipe/issues/events{/number}","events_url":"https://api.github.com/repos/edjafarov/PromisePipe/events","assignees_url":"https://api.github.com/repos/edjafarov/PromisePipe/assignees{/user}","branches_url":"https://api.github.com/repos/edjafarov/PromisePipe/branches{/branch}","tags_url":"https://api.github.com/repos/edjafarov/PromisePipe/tags","blobs_url":"https://api.github.com/repos/edjafarov/PromisePipe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edjafarov/PromisePipe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edjafarov/PromisePipe/git/refs{/sha}","trees_url":"https://api.github.com/repos/edjafarov/PromisePipe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edjafarov/PromisePipe/statuses/{sha}","languages_url":"https://api.github.com/repos/edjafarov/PromisePipe/languages","stargazers_url":"https://api.github.com/repos/edjafarov/PromisePipe/stargazers","contributors_url":"https://api.github.com/repos/edjafarov/PromisePipe/contributors","subscribers_url":"https://api.github.com/repos/edjafarov/PromisePipe/subscribers","subscription_url":"https://api.github.com/repos/edjafarov/PromisePipe/subscription","commits_url":"https://api.github.com/repos/edjafarov/PromisePipe/commits{/sha}","git_commits_url":"https://api.github.com/repos/edjafarov/PromisePipe/git/commits{/sha}","comments_url":"https://api.github.com/repos/edjafarov/PromisePipe/comments{/number}","issue_comment_url":"https://api.github.com/repos/edjafarov/PromisePipe/issues/comments{/number}","contents_url":"https://api.github.com/repos/edjafarov/PromisePipe/contents/{+path}","compare_url":"https://api.github.com/repos/edjafarov/PromisePipe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edjafarov/PromisePipe/merges","archive_url":"https://api.github.com/repos/edjafarov/PromisePipe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edjafarov/PromisePipe/downloads","issues_url":"https://api.github.com/repos/edjafarov/PromisePipe/issues{/number}","pulls_url":"https://api.github.com/repos/edjafarov/PromisePipe/pulls{/number}","milestones_url":"https://api.github.com/repos/edjafarov/PromisePipe/milestones{/number}","notifications_url":"https://api.github.com/repos/edjafarov/PromisePipe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edjafarov/PromisePipe/labels{/name}","releases_url":"https://api.github.com/repos/edjafarov/PromisePipe/releases{/id}","created_at":"2015-01-26T18:31:01Z","updated_at":"2015-07-22T12:29:47Z","pushed_at":"2015-07-22T18:27:13Z","git_url":"git://github.com/edjafarov/PromisePipe.git","ssh_url":"git@github.com:edjafarov/PromisePipe.git","clone_url":"https://github.com/edjafarov/PromisePipe.git","svn_url":"https://github.com/edjafarov/PromisePipe","homepage":"","size":557,"stargazers_count":43,"watchers_count":43,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":11,"forks":5,"open_issues":11,"watchers":43,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/29"},"html":{"href":"https://github.com/edjafarov/PromisePipe/pull/29"},"issue":{"href":"https://api.github.com/repos/edjafarov/PromisePipe/issues/29"},"comments":{"href":"https://api.github.com/repos/edjafarov/PromisePipe/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edjafarov/PromisePipe/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/edjafarov/PromisePipe/statuses/038b616ca5e7f6c8ed50c6b282ed22a263b3923f"}}}}