{"action":"created","comment":{"url":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/comments/235530006","pull_request_review_id":177416394,"id":235530006,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNTUzMDAwNg==","diff_hunk":"@@ -0,0 +1,121 @@\n+const request = require('request');\n+const cheerio = require('cheerio');\n+const express = require('express');\n+const bodyParser = require('body-parser');\n+const consolidate = require('consolidate');\n+const path = require('path');\n+const mongoose = require('mongoose');\n+const passport = require('passport');\n+const LocalStrategy = require('passport-local').Strategy;\n+\n+// подключение экспресса, регистрация боди парсера\n+mongoose.connect('mongodb://localhost/task', {useNewUrlParser:true});\n+mongoose.connect('mongodb://localhost/users', {useNewUrlParser:true})\n+const Task = require('./models/task');\n+const User = require('./models/users');\n+const app = express();\n+\n+app.use(bodyParser.urlencoded({\n+\textended: true\n+}));\n+app.use(bodyParser.json());\n+app.engine('hbs', consolidate.handlebars);\n+app.set('view engine', 'hbs');\n+app.set('views', path.resolve(__dirname, 'views'))\n+app.use(passport.initialize());\n+app.use(passport.session());\n+\n+const authHandler = passport.authenticate('local', {\n+\tsuccessRedirect: '/user',\n+\tfailureRedirect: '/auth',\n+})\n+\n+const mustBeAuthenticated = (req,res,next)=>{\n+\tif (req.user){\n+\t\tnext();\n+\t} else {\n+\t\tres.redirect('/auth');\n+\t}\n+}\n+\n+passport.use(new LocalStrategy(\n+function(username, password, done) { \n+    User.findOne({ 'username' :  username }, \n+    \tfunction(err, user) {\n+        if (err)\n+        \treturn done(err);\n+        if (!user){\n+        \tconsole.log('User Not Found with username '+username);\n+        \treturn done(null, false, \n+        \t\tconsole.log('User Not found.'));                 \n+        }\n+        return done(null, user);\n+      }\n+      );\n+  }));\n+\n+passport.serializeUser((user,done)=>{\n+\tdone(null,user._id);\n+})\n+passport.deserializeUser((id,done)=>{\n+\tUser.findById(id, (err,user)=>{\n+\t\tdone(err,user);\n+\t})\n+})\n+\n+// логика\n+app.all('/user', mustBeAuthenticated)\n+app.get('/user', async (req,res)=>{\n+\tlet users = await User.find();\n+\tres.json(users);\n+})\n+app.get('/auth', async (req,res)=>{\n+\tres.render('login');\n+})\n+app.post('/auth', authHandler); \n+app.get('/tasks', async (req,res)=> {\n+\tlet tasks = [];\n+\ttasks = await Task.find();\n+\tconsole.log(tasks)\n+\tres.render('list', {\n+\t\tcards: tasks\n+\t});\n+})\n+app.post('/tasks', async (req,res)=>{\n+\tlet task = new Task(req.body);\n+\ttask = await task.save();\n+\tres.json(tasks);\n+})\n+app.get('/tasks/delete', async (req,res)=> {\n+\tconst tasks = await Task.find();\n+\tres.json(tasks);\n+})\n+app.post('/tasks/delete', async (req,res)=>{\n+\tconsole.log(req.body.name)\n+\tlet one = req.body.id\n+\tconsole.log(one)\n+\tconst tasks = await Task.deleteOne({\"content\":req.body.content}, (err)=>{\n+\t\tres.send('запрос прошел')\n+\t\t})\n+\t});\n+\n+//update\n+app.get('/tasks/update', async (req,res)=> {\n+\tconst tasks = await Task.find();\n+\tres.json(tasks);\n+})\n+app.post('/tasks/update', async (req,res)=>{\n+\tconsole.log(req.body.name)\n+\tlet one = req.body.id\n+\tconsole.log(one)","path":"Aibek/lesson6/server.js","position":110,"original_position":110,"commit_id":"95ab1058e1d46effa4c44c68622b03000d770dde","original_commit_id":"95ab1058e1d46effa4c44c68622b03000d770dde","user":{"login":"ubcent","id":4948124,"node_id":"MDQ6VXNlcjQ5NDgxMjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/4948124?v=4","gravatar_id":"","url":"https://api.github.com/users/ubcent","html_url":"https://github.com/ubcent","followers_url":"https://api.github.com/users/ubcent/followers","following_url":"https://api.github.com/users/ubcent/following{/other_user}","gists_url":"https://api.github.com/users/ubcent/gists{/gist_id}","starred_url":"https://api.github.com/users/ubcent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubcent/subscriptions","organizations_url":"https://api.github.com/users/ubcent/orgs","repos_url":"https://api.github.com/users/ubcent/repos","events_url":"https://api.github.com/users/ubcent/events{/privacy}","received_events_url":"https://api.github.com/users/ubcent/received_events","type":"User","site_admin":false},"body":"```suggestion\r\n```","created_at":"2018-11-21T20:28:17Z","updated_at":"2018-11-21T20:30:03Z","html_url":"https://github.com/ubcent/node.js-27.10/pull/23#discussion_r235530006","pull_request_url":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/23","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/comments/235530006"},"html":{"href":"https://github.com/ubcent/node.js-27.10/pull/23#discussion_r235530006"},"pull_request":{"href":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/23"}}},"pull_request":{"url":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/23","id":232738694,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMyNzM4Njk0","html_url":"https://github.com/ubcent/node.js-27.10/pull/23","diff_url":"https://github.com/ubcent/node.js-27.10/pull/23.diff","patch_url":"https://github.com/ubcent/node.js-27.10/pull/23.patch","issue_url":"https://api.github.com/repos/ubcent/node.js-27.10/issues/23","number":23,"state":"open","locked":false,"title":"homework6 Aibek","user":{"login":"aibekanv","id":31644989,"node_id":"MDQ6VXNlcjMxNjQ0OTg5","avatar_url":"https://avatars2.githubusercontent.com/u/31644989?v=4","gravatar_id":"","url":"https://api.github.com/users/aibekanv","html_url":"https://github.com/aibekanv","followers_url":"https://api.github.com/users/aibekanv/followers","following_url":"https://api.github.com/users/aibekanv/following{/other_user}","gists_url":"https://api.github.com/users/aibekanv/gists{/gist_id}","starred_url":"https://api.github.com/users/aibekanv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aibekanv/subscriptions","organizations_url":"https://api.github.com/users/aibekanv/orgs","repos_url":"https://api.github.com/users/aibekanv/repos","events_url":"https://api.github.com/users/aibekanv/events{/privacy}","received_events_url":"https://api.github.com/users/aibekanv/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-11-21T17:04:31Z","updated_at":"2018-11-21T20:30:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6b903e3ebd02bdf4a2be0b8b29ee02ef85ec26b2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/23/commits","review_comments_url":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/23/comments","review_comment_url":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ubcent/node.js-27.10/issues/23/comments","statuses_url":"https://api.github.com/repos/ubcent/node.js-27.10/statuses/95ab1058e1d46effa4c44c68622b03000d770dde","head":{"label":"aibekanv:master","ref":"master","sha":"95ab1058e1d46effa4c44c68622b03000d770dde","user":{"login":"aibekanv","id":31644989,"node_id":"MDQ6VXNlcjMxNjQ0OTg5","avatar_url":"https://avatars2.githubusercontent.com/u/31644989?v=4","gravatar_id":"","url":"https://api.github.com/users/aibekanv","html_url":"https://github.com/aibekanv","followers_url":"https://api.github.com/users/aibekanv/followers","following_url":"https://api.github.com/users/aibekanv/following{/other_user}","gists_url":"https://api.github.com/users/aibekanv/gists{/gist_id}","starred_url":"https://api.github.com/users/aibekanv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aibekanv/subscriptions","organizations_url":"https://api.github.com/users/aibekanv/orgs","repos_url":"https://api.github.com/users/aibekanv/repos","events_url":"https://api.github.com/users/aibekanv/events{/privacy}","received_events_url":"https://api.github.com/users/aibekanv/received_events","type":"User","site_admin":false},"repo":{"id":155680134,"node_id":"MDEwOlJlcG9zaXRvcnkxNTU2ODAxMzQ=","name":"node.js-27.10","full_name":"aibekanv/node.js-27.10","private":false,"owner":{"login":"aibekanv","id":31644989,"node_id":"MDQ6VXNlcjMxNjQ0OTg5","avatar_url":"https://avatars2.githubusercontent.com/u/31644989?v=4","gravatar_id":"","url":"https://api.github.com/users/aibekanv","html_url":"https://github.com/aibekanv","followers_url":"https://api.github.com/users/aibekanv/followers","following_url":"https://api.github.com/users/aibekanv/following{/other_user}","gists_url":"https://api.github.com/users/aibekanv/gists{/gist_id}","starred_url":"https://api.github.com/users/aibekanv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aibekanv/subscriptions","organizations_url":"https://api.github.com/users/aibekanv/orgs","repos_url":"https://api.github.com/users/aibekanv/repos","events_url":"https://api.github.com/users/aibekanv/events{/privacy}","received_events_url":"https://api.github.com/users/aibekanv/received_events","type":"User","site_admin":false},"html_url":"https://github.com/aibekanv/node.js-27.10","description":null,"fork":true,"url":"https://api.github.com/repos/aibekanv/node.js-27.10","forks_url":"https://api.github.com/repos/aibekanv/node.js-27.10/forks","keys_url":"https://api.github.com/repos/aibekanv/node.js-27.10/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aibekanv/node.js-27.10/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aibekanv/node.js-27.10/teams","hooks_url":"https://api.github.com/repos/aibekanv/node.js-27.10/hooks","issue_events_url":"https://api.github.com/repos/aibekanv/node.js-27.10/issues/events{/number}","events_url":"https://api.github.com/repos/aibekanv/node.js-27.10/events","assignees_url":"https://api.github.com/repos/aibekanv/node.js-27.10/assignees{/user}","branches_url":"https://api.github.com/repos/aibekanv/node.js-27.10/branches{/branch}","tags_url":"https://api.github.com/repos/aibekanv/node.js-27.10/tags","blobs_url":"https://api.github.com/repos/aibekanv/node.js-27.10/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aibekanv/node.js-27.10/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aibekanv/node.js-27.10/git/refs{/sha}","trees_url":"https://api.github.com/repos/aibekanv/node.js-27.10/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aibekanv/node.js-27.10/statuses/{sha}","languages_url":"https://api.github.com/repos/aibekanv/node.js-27.10/languages","stargazers_url":"https://api.github.com/repos/aibekanv/node.js-27.10/stargazers","contributors_url":"https://api.github.com/repos/aibekanv/node.js-27.10/contributors","subscribers_url":"https://api.github.com/repos/aibekanv/node.js-27.10/subscribers","subscription_url":"https://api.github.com/repos/aibekanv/node.js-27.10/subscription","commits_url":"https://api.github.com/repos/aibekanv/node.js-27.10/commits{/sha}","git_commits_url":"https://api.github.com/repos/aibekanv/node.js-27.10/git/commits{/sha}","comments_url":"https://api.github.com/repos/aibekanv/node.js-27.10/comments{/number}","issue_comment_url":"https://api.github.com/repos/aibekanv/node.js-27.10/issues/comments{/number}","contents_url":"https://api.github.com/repos/aibekanv/node.js-27.10/contents/{+path}","compare_url":"https://api.github.com/repos/aibekanv/node.js-27.10/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aibekanv/node.js-27.10/merges","archive_url":"https://api.github.com/repos/aibekanv/node.js-27.10/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aibekanv/node.js-27.10/downloads","issues_url":"https://api.github.com/repos/aibekanv/node.js-27.10/issues{/number}","pulls_url":"https://api.github.com/repos/aibekanv/node.js-27.10/pulls{/number}","milestones_url":"https://api.github.com/repos/aibekanv/node.js-27.10/milestones{/number}","notifications_url":"https://api.github.com/repos/aibekanv/node.js-27.10/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aibekanv/node.js-27.10/labels{/name}","releases_url":"https://api.github.com/repos/aibekanv/node.js-27.10/releases{/id}","deployments_url":"https://api.github.com/repos/aibekanv/node.js-27.10/deployments","created_at":"2018-11-01T07:46:46Z","updated_at":"2018-11-21T17:02:52Z","pushed_at":"2018-11-21T17:02:50Z","git_url":"git://github.com/aibekanv/node.js-27.10.git","ssh_url":"git@github.com:aibekanv/node.js-27.10.git","clone_url":"https://github.com/aibekanv/node.js-27.10.git","svn_url":"https://github.com/aibekanv/node.js-27.10","homepage":null,"size":19,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ubcent:master","ref":"master","sha":"fab5aa09da0d1036313bc462b0f12761f006b0dc","user":{"login":"ubcent","id":4948124,"node_id":"MDQ6VXNlcjQ5NDgxMjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/4948124?v=4","gravatar_id":"","url":"https://api.github.com/users/ubcent","html_url":"https://github.com/ubcent","followers_url":"https://api.github.com/users/ubcent/followers","following_url":"https://api.github.com/users/ubcent/following{/other_user}","gists_url":"https://api.github.com/users/ubcent/gists{/gist_id}","starred_url":"https://api.github.com/users/ubcent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubcent/subscriptions","organizations_url":"https://api.github.com/users/ubcent/orgs","repos_url":"https://api.github.com/users/ubcent/repos","events_url":"https://api.github.com/users/ubcent/events{/privacy}","received_events_url":"https://api.github.com/users/ubcent/received_events","type":"User","site_admin":false},"repo":{"id":155590438,"node_id":"MDEwOlJlcG9zaXRvcnkxNTU1OTA0Mzg=","name":"node.js-27.10","full_name":"ubcent/node.js-27.10","private":false,"owner":{"login":"ubcent","id":4948124,"node_id":"MDQ6VXNlcjQ5NDgxMjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/4948124?v=4","gravatar_id":"","url":"https://api.github.com/users/ubcent","html_url":"https://github.com/ubcent","followers_url":"https://api.github.com/users/ubcent/followers","following_url":"https://api.github.com/users/ubcent/following{/other_user}","gists_url":"https://api.github.com/users/ubcent/gists{/gist_id}","starred_url":"https://api.github.com/users/ubcent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubcent/subscriptions","organizations_url":"https://api.github.com/users/ubcent/orgs","repos_url":"https://api.github.com/users/ubcent/repos","events_url":"https://api.github.com/users/ubcent/events{/privacy}","received_events_url":"https://api.github.com/users/ubcent/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ubcent/node.js-27.10","description":null,"fork":false,"url":"https://api.github.com/repos/ubcent/node.js-27.10","forks_url":"https://api.github.com/repos/ubcent/node.js-27.10/forks","keys_url":"https://api.github.com/repos/ubcent/node.js-27.10/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ubcent/node.js-27.10/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ubcent/node.js-27.10/teams","hooks_url":"https://api.github.com/repos/ubcent/node.js-27.10/hooks","issue_events_url":"https://api.github.com/repos/ubcent/node.js-27.10/issues/events{/number}","events_url":"https://api.github.com/repos/ubcent/node.js-27.10/events","assignees_url":"https://api.github.com/repos/ubcent/node.js-27.10/assignees{/user}","branches_url":"https://api.github.com/repos/ubcent/node.js-27.10/branches{/branch}","tags_url":"https://api.github.com/repos/ubcent/node.js-27.10/tags","blobs_url":"https://api.github.com/repos/ubcent/node.js-27.10/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ubcent/node.js-27.10/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ubcent/node.js-27.10/git/refs{/sha}","trees_url":"https://api.github.com/repos/ubcent/node.js-27.10/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ubcent/node.js-27.10/statuses/{sha}","languages_url":"https://api.github.com/repos/ubcent/node.js-27.10/languages","stargazers_url":"https://api.github.com/repos/ubcent/node.js-27.10/stargazers","contributors_url":"https://api.github.com/repos/ubcent/node.js-27.10/contributors","subscribers_url":"https://api.github.com/repos/ubcent/node.js-27.10/subscribers","subscription_url":"https://api.github.com/repos/ubcent/node.js-27.10/subscription","commits_url":"https://api.github.com/repos/ubcent/node.js-27.10/commits{/sha}","git_commits_url":"https://api.github.com/repos/ubcent/node.js-27.10/git/commits{/sha}","comments_url":"https://api.github.com/repos/ubcent/node.js-27.10/comments{/number}","issue_comment_url":"https://api.github.com/repos/ubcent/node.js-27.10/issues/comments{/number}","contents_url":"https://api.github.com/repos/ubcent/node.js-27.10/contents/{+path}","compare_url":"https://api.github.com/repos/ubcent/node.js-27.10/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ubcent/node.js-27.10/merges","archive_url":"https://api.github.com/repos/ubcent/node.js-27.10/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ubcent/node.js-27.10/downloads","issues_url":"https://api.github.com/repos/ubcent/node.js-27.10/issues{/number}","pulls_url":"https://api.github.com/repos/ubcent/node.js-27.10/pulls{/number}","milestones_url":"https://api.github.com/repos/ubcent/node.js-27.10/milestones{/number}","notifications_url":"https://api.github.com/repos/ubcent/node.js-27.10/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ubcent/node.js-27.10/labels{/name}","releases_url":"https://api.github.com/repos/ubcent/node.js-27.10/releases{/id}","deployments_url":"https://api.github.com/repos/ubcent/node.js-27.10/deployments","created_at":"2018-10-31T16:35:13Z","updated_at":"2018-11-21T19:01:25Z","pushed_at":"2018-11-21T19:01:23Z","git_url":"git://github.com/ubcent/node.js-27.10.git","ssh_url":"git@github.com:ubcent/node.js-27.10.git","clone_url":"https://github.com/ubcent/node.js-27.10.git","svn_url":"https://github.com/ubcent/node.js-27.10","homepage":null,"size":363,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":4,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/23"},"html":{"href":"https://github.com/ubcent/node.js-27.10/pull/23"},"issue":{"href":"https://api.github.com/repos/ubcent/node.js-27.10/issues/23"},"comments":{"href":"https://api.github.com/repos/ubcent/node.js-27.10/issues/23/comments"},"review_comments":{"href":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/23/comments"},"review_comment":{"href":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ubcent/node.js-27.10/pulls/23/commits"},"statuses":{"href":"https://api.github.com/repos/ubcent/node.js-27.10/statuses/95ab1058e1d46effa4c44c68622b03000d770dde"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ubcent"}}