{"action":"created","comment":{"url":"https://api.github.com/repos/strongloop/loopback-next/pulls/comments/193885975","pull_request_review_id":126952626,"id":193885975,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5Mzg4NTk3NQ==","diff_hunk":"@@ -0,0 +1,114 @@\n+// Copyright IBM Corp. 2017,2018. All Rights Reserved.\n+// Node module: @loopback/http-server\n+// This file is licensed under the MIT License.\n+// License text available at https://opensource.org/licenses/MIT\n+\n+import {createServer, Server, ServerRequest, ServerResponse} from 'http';\n+import {AddressInfo} from 'net';\n+import * as pEvent from 'p-event';\n+\n+export type HttpRequestListener = (\n+  req: ServerRequest,\n+  res: ServerResponse,\n+) => void;\n+\n+/**\n+ * Object for specifyig the HTTP / HTTPS server options\n+ */\n+export type HttpServerOptions = {\n+  port?: number;\n+  host?: string;\n+  protocol?: HttpProtocol;\n+};\n+\n+export type HttpProtocol = 'http' | 'https'; // Will be extended to `http2` in the future\n+\n+/**\n+ * HTTP / HTTPS server used by LoopBack's RestServer\n+ *\n+ * @export\n+ * @class HttpServer\n+ */\n+export class HttpServer {\n+  private _port: number;\n+  private _host?: string;\n+  /**\n+   * Protocol, default to `http`\n+   */\n+  private _protocol: HttpProtocol;\n+  private _address: AddressInfo;\n+  private httpRequestListener: HttpRequestListener;\n+  private httpServer: Server;\n+\n+  /**\n+   * @param httpServerOptions\n+   * @param httpRequestListener\n+   */\n+  constructor(\n+    httpRequestListener: HttpRequestListener,\n+    httpServerOptions?: HttpServerOptions,\n+  ) {\n+    this.httpRequestListener = httpRequestListener;\n+    if (!httpServerOptions) httpServerOptions = {};\n+    this._port = httpServerOptions.port || 0;\n+    this._host = httpServerOptions.host || undefined;\n+    this._protocol = httpServerOptions.protocol || 'http';\n+  }\n+\n+  /**\n+   * Starts the HTTP / HTTPS server\n+   */\n+  public async start() {\n+    this.httpServer = createServer(this.httpRequestListener);\n+    this.httpServer.listen(this._port, this._host);\n+    await pEvent(this.httpServer, 'listening');\n+    this._address = this.httpServer.address() as AddressInfo;\n+    this._host = this._host || this._address.address;\n+    this._port = this._address.port;\n+  }\n+\n+  /**\n+   * Stops the HTTP / HTTPS server\n+   */\n+  public async stop() {\n+    if (this.httpServer) {\n+      this.httpServer.close();","path":"packages/http-server/src/http-server.ts","position":75,"original_position":75,"commit_id":"c3223808843b0826a278af835a63f9982fb470cd","original_commit_id":"c3223808843b0826a278af835a63f9982fb470cd","user":{"login":"hacksparrow","id":950112,"node_id":"MDQ6VXNlcjk1MDExMg==","avatar_url":"https://avatars3.githubusercontent.com/u/950112?v=4","gravatar_id":"","url":"https://api.github.com/users/hacksparrow","html_url":"https://github.com/hacksparrow","followers_url":"https://api.github.com/users/hacksparrow/followers","following_url":"https://api.github.com/users/hacksparrow/following{/other_user}","gists_url":"https://api.github.com/users/hacksparrow/gists{/gist_id}","starred_url":"https://api.github.com/users/hacksparrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hacksparrow/subscriptions","organizations_url":"https://api.github.com/users/hacksparrow/orgs","repos_url":"https://api.github.com/users/hacksparrow/repos","events_url":"https://api.github.com/users/hacksparrow/events{/privacy}","received_events_url":"https://api.github.com/users/hacksparrow/received_events","type":"User","site_admin":false},"body":"Added.","created_at":"2018-06-07T20:53:41Z","updated_at":"2018-06-07T20:53:42Z","html_url":"https://github.com/strongloop/loopback-next/pull/1369#discussion_r193885975","pull_request_url":"https://api.github.com/repos/strongloop/loopback-next/pulls/1369","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/strongloop/loopback-next/pulls/comments/193885975"},"html":{"href":"https://github.com/strongloop/loopback-next/pull/1369#discussion_r193885975"},"pull_request":{"href":"https://api.github.com/repos/strongloop/loopback-next/pulls/1369"}},"in_reply_to_id":193499178},"pull_request":{"url":"https://api.github.com/repos/strongloop/loopback-next/pulls/1369","id":190992001,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkwOTkyMDAx","html_url":"https://github.com/strongloop/loopback-next/pull/1369","diff_url":"https://github.com/strongloop/loopback-next/pull/1369.diff","patch_url":"https://github.com/strongloop/loopback-next/pull/1369.patch","issue_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1369","number":1369,"state":"open","locked":false,"title":"Implement HTTP endpoint factory","user":{"login":"hacksparrow","id":950112,"node_id":"MDQ6VXNlcjk1MDExMg==","avatar_url":"https://avatars3.githubusercontent.com/u/950112?v=4","gravatar_id":"","url":"https://api.github.com/users/hacksparrow","html_url":"https://github.com/hacksparrow","followers_url":"https://api.github.com/users/hacksparrow/followers","following_url":"https://api.github.com/users/hacksparrow/following{/other_user}","gists_url":"https://api.github.com/users/hacksparrow/gists{/gist_id}","starred_url":"https://api.github.com/users/hacksparrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hacksparrow/subscriptions","organizations_url":"https://api.github.com/users/hacksparrow/orgs","repos_url":"https://api.github.com/users/hacksparrow/repos","events_url":"https://api.github.com/users/hacksparrow/events{/privacy}","received_events_url":"https://api.github.com/users/hacksparrow/received_events","type":"User","site_admin":false},"body":"Implements #1331.\r\n\r\nMain changes:\r\n\r\n1. Added a new package `@loopback/http-server`\r\n2. Made changes to `@loopback/rest` to use `@loopback/http-server`. \r\n\r\n## Checklist\r\n\r\n- [x] `npm test` passes on your machine\r\n- [x] New tests added or existing tests modified to cover all changes\r\n- [x] Code conforms with the [style guide](http://loopback.io/doc/en/contrib/style-guide.html)\r\n- [x] API Documentation in code was updated\r\n- [ ] Documentation in [/docs/site](../tree/master/docs/site) was updated\r\n- [ ] Affected artifact templates in `packages/cli` were updated\r\n- [ ] Affected example projects in `examples/*` were updated\r\n","created_at":"2018-05-28T20:20:33Z","updated_at":"2018-06-07T20:53:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bfd36960a2958f812303ec8bb3be06de9d16ccc9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/strongloop/loopback-next/pulls/1369/commits","review_comments_url":"https://api.github.com/repos/strongloop/loopback-next/pulls/1369/comments","review_comment_url":"https://api.github.com/repos/strongloop/loopback-next/pulls/comments{/number}","comments_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1369/comments","statuses_url":"https://api.github.com/repos/strongloop/loopback-next/statuses/c3223808843b0826a278af835a63f9982fb470cd","head":{"label":"strongloop:package/http-server","ref":"package/http-server","sha":"c3223808843b0826a278af835a63f9982fb470cd","user":{"login":"strongloop","id":3020012,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMwMjAwMTI=","avatar_url":"https://avatars1.githubusercontent.com/u/3020012?v=4","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"repo":{"id":78452015,"node_id":"MDEwOlJlcG9zaXRvcnk3ODQ1MjAxNQ==","name":"loopback-next","full_name":"strongloop/loopback-next","owner":{"login":"strongloop","id":3020012,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMwMjAwMTI=","avatar_url":"https://avatars1.githubusercontent.com/u/3020012?v=4","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strongloop/loopback-next","description":"LoopBack makes it easy to build modern API applications that require complex integrations.","fork":false,"url":"https://api.github.com/repos/strongloop/loopback-next","forks_url":"https://api.github.com/repos/strongloop/loopback-next/forks","keys_url":"https://api.github.com/repos/strongloop/loopback-next/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strongloop/loopback-next/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strongloop/loopback-next/teams","hooks_url":"https://api.github.com/repos/strongloop/loopback-next/hooks","issue_events_url":"https://api.github.com/repos/strongloop/loopback-next/issues/events{/number}","events_url":"https://api.github.com/repos/strongloop/loopback-next/events","assignees_url":"https://api.github.com/repos/strongloop/loopback-next/assignees{/user}","branches_url":"https://api.github.com/repos/strongloop/loopback-next/branches{/branch}","tags_url":"https://api.github.com/repos/strongloop/loopback-next/tags","blobs_url":"https://api.github.com/repos/strongloop/loopback-next/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strongloop/loopback-next/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strongloop/loopback-next/git/refs{/sha}","trees_url":"https://api.github.com/repos/strongloop/loopback-next/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strongloop/loopback-next/statuses/{sha}","languages_url":"https://api.github.com/repos/strongloop/loopback-next/languages","stargazers_url":"https://api.github.com/repos/strongloop/loopback-next/stargazers","contributors_url":"https://api.github.com/repos/strongloop/loopback-next/contributors","subscribers_url":"https://api.github.com/repos/strongloop/loopback-next/subscribers","subscription_url":"https://api.github.com/repos/strongloop/loopback-next/subscription","commits_url":"https://api.github.com/repos/strongloop/loopback-next/commits{/sha}","git_commits_url":"https://api.github.com/repos/strongloop/loopback-next/git/commits{/sha}","comments_url":"https://api.github.com/repos/strongloop/loopback-next/comments{/number}","issue_comment_url":"https://api.github.com/repos/strongloop/loopback-next/issues/comments{/number}","contents_url":"https://api.github.com/repos/strongloop/loopback-next/contents/{+path}","compare_url":"https://api.github.com/repos/strongloop/loopback-next/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strongloop/loopback-next/merges","archive_url":"https://api.github.com/repos/strongloop/loopback-next/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strongloop/loopback-next/downloads","issues_url":"https://api.github.com/repos/strongloop/loopback-next/issues{/number}","pulls_url":"https://api.github.com/repos/strongloop/loopback-next/pulls{/number}","milestones_url":"https://api.github.com/repos/strongloop/loopback-next/milestones{/number}","notifications_url":"https://api.github.com/repos/strongloop/loopback-next/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strongloop/loopback-next/labels{/name}","releases_url":"https://api.github.com/repos/strongloop/loopback-next/releases{/id}","deployments_url":"https://api.github.com/repos/strongloop/loopback-next/deployments","created_at":"2017-01-09T17:27:14Z","updated_at":"2018-06-07T20:45:42Z","pushed_at":"2018-06-07T20:40:57Z","git_url":"git://github.com/strongloop/loopback-next.git","ssh_url":"git@github.com:strongloop/loopback-next.git","clone_url":"https://github.com/strongloop/loopback-next.git","svn_url":"https://github.com/strongloop/loopback-next","homepage":"http://loopback.io","size":6243,"stargazers_count":635,"watchers_count":635,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":63,"mirror_url":null,"archived":false,"open_issues_count":234,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":63,"open_issues":234,"watchers":635,"default_branch":"master"}},"base":{"label":"strongloop:master","ref":"master","sha":"825d8426243eee51a36f8dd1981c0a91c1feabc9","user":{"login":"strongloop","id":3020012,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMwMjAwMTI=","avatar_url":"https://avatars1.githubusercontent.com/u/3020012?v=4","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"repo":{"id":78452015,"node_id":"MDEwOlJlcG9zaXRvcnk3ODQ1MjAxNQ==","name":"loopback-next","full_name":"strongloop/loopback-next","owner":{"login":"strongloop","id":3020012,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMwMjAwMTI=","avatar_url":"https://avatars1.githubusercontent.com/u/3020012?v=4","gravatar_id":"","url":"https://api.github.com/users/strongloop","html_url":"https://github.com/strongloop","followers_url":"https://api.github.com/users/strongloop/followers","following_url":"https://api.github.com/users/strongloop/following{/other_user}","gists_url":"https://api.github.com/users/strongloop/gists{/gist_id}","starred_url":"https://api.github.com/users/strongloop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/strongloop/subscriptions","organizations_url":"https://api.github.com/users/strongloop/orgs","repos_url":"https://api.github.com/users/strongloop/repos","events_url":"https://api.github.com/users/strongloop/events{/privacy}","received_events_url":"https://api.github.com/users/strongloop/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/strongloop/loopback-next","description":"LoopBack makes it easy to build modern API applications that require complex integrations.","fork":false,"url":"https://api.github.com/repos/strongloop/loopback-next","forks_url":"https://api.github.com/repos/strongloop/loopback-next/forks","keys_url":"https://api.github.com/repos/strongloop/loopback-next/keys{/key_id}","collaborators_url":"https://api.github.com/repos/strongloop/loopback-next/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/strongloop/loopback-next/teams","hooks_url":"https://api.github.com/repos/strongloop/loopback-next/hooks","issue_events_url":"https://api.github.com/repos/strongloop/loopback-next/issues/events{/number}","events_url":"https://api.github.com/repos/strongloop/loopback-next/events","assignees_url":"https://api.github.com/repos/strongloop/loopback-next/assignees{/user}","branches_url":"https://api.github.com/repos/strongloop/loopback-next/branches{/branch}","tags_url":"https://api.github.com/repos/strongloop/loopback-next/tags","blobs_url":"https://api.github.com/repos/strongloop/loopback-next/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/strongloop/loopback-next/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/strongloop/loopback-next/git/refs{/sha}","trees_url":"https://api.github.com/repos/strongloop/loopback-next/git/trees{/sha}","statuses_url":"https://api.github.com/repos/strongloop/loopback-next/statuses/{sha}","languages_url":"https://api.github.com/repos/strongloop/loopback-next/languages","stargazers_url":"https://api.github.com/repos/strongloop/loopback-next/stargazers","contributors_url":"https://api.github.com/repos/strongloop/loopback-next/contributors","subscribers_url":"https://api.github.com/repos/strongloop/loopback-next/subscribers","subscription_url":"https://api.github.com/repos/strongloop/loopback-next/subscription","commits_url":"https://api.github.com/repos/strongloop/loopback-next/commits{/sha}","git_commits_url":"https://api.github.com/repos/strongloop/loopback-next/git/commits{/sha}","comments_url":"https://api.github.com/repos/strongloop/loopback-next/comments{/number}","issue_comment_url":"https://api.github.com/repos/strongloop/loopback-next/issues/comments{/number}","contents_url":"https://api.github.com/repos/strongloop/loopback-next/contents/{+path}","compare_url":"https://api.github.com/repos/strongloop/loopback-next/compare/{base}...{head}","merges_url":"https://api.github.com/repos/strongloop/loopback-next/merges","archive_url":"https://api.github.com/repos/strongloop/loopback-next/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/strongloop/loopback-next/downloads","issues_url":"https://api.github.com/repos/strongloop/loopback-next/issues{/number}","pulls_url":"https://api.github.com/repos/strongloop/loopback-next/pulls{/number}","milestones_url":"https://api.github.com/repos/strongloop/loopback-next/milestones{/number}","notifications_url":"https://api.github.com/repos/strongloop/loopback-next/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/strongloop/loopback-next/labels{/name}","releases_url":"https://api.github.com/repos/strongloop/loopback-next/releases{/id}","deployments_url":"https://api.github.com/repos/strongloop/loopback-next/deployments","created_at":"2017-01-09T17:27:14Z","updated_at":"2018-06-07T20:45:42Z","pushed_at":"2018-06-07T20:40:57Z","git_url":"git://github.com/strongloop/loopback-next.git","ssh_url":"git@github.com:strongloop/loopback-next.git","clone_url":"https://github.com/strongloop/loopback-next.git","svn_url":"https://github.com/strongloop/loopback-next","homepage":"http://loopback.io","size":6243,"stargazers_count":635,"watchers_count":635,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":63,"mirror_url":null,"archived":false,"open_issues_count":234,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":63,"open_issues":234,"watchers":635,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/strongloop/loopback-next/pulls/1369"},"html":{"href":"https://github.com/strongloop/loopback-next/pull/1369"},"issue":{"href":"https://api.github.com/repos/strongloop/loopback-next/issues/1369"},"comments":{"href":"https://api.github.com/repos/strongloop/loopback-next/issues/1369/comments"},"review_comments":{"href":"https://api.github.com/repos/strongloop/loopback-next/pulls/1369/comments"},"review_comment":{"href":"https://api.github.com/repos/strongloop/loopback-next/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/strongloop/loopback-next/pulls/1369/commits"},"statuses":{"href":"https://api.github.com/repos/strongloop/loopback-next/statuses/c3223808843b0826a278af835a63f9982fb470cd"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"hacksparrow"}}