{"action":"created","issue":{"url":"https://api.github.com/repos/shipharbor/merry/issues/88","repository_url":"https://api.github.com/repos/shipharbor/merry","labels_url":"https://api.github.com/repos/shipharbor/merry/issues/88/labels{/name}","comments_url":"https://api.github.com/repos/shipharbor/merry/issues/88/comments","events_url":"https://api.github.com/repos/shipharbor/merry/issues/88/events","html_url":"https://github.com/shipharbor/merry/issues/88","id":232456881,"number":88,"title":"unclear how to set default PORT","user":{"login":"mattiaerre","id":6423261,"avatar_url":"https://avatars0.githubusercontent.com/u/6423261?v=3","gravatar_id":"","url":"https://api.github.com/users/mattiaerre","html_url":"https://github.com/mattiaerre","followers_url":"https://api.github.com/users/mattiaerre/followers","following_url":"https://api.github.com/users/mattiaerre/following{/other_user}","gists_url":"https://api.github.com/users/mattiaerre/gists{/gist_id}","starred_url":"https://api.github.com/users/mattiaerre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattiaerre/subscriptions","organizations_url":"https://api.github.com/users/mattiaerre/orgs","repos_url":"https://api.github.com/users/mattiaerre/repos","events_url":"https://api.github.com/users/mattiaerre/events{/privacy}","received_events_url":"https://api.github.com/users/mattiaerre/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-05-31T05:25:02Z","updated_at":"2017-05-31T22:17:36Z","closed_at":null,"body":"# Description\r\n\r\nfollowing [this example](https://github.com/shipharbor/merry#configuration), it is not possible to have a default `process.env.PORT` for the HTTP server.\r\nit looks like the constructor doesn't take into account the `env` part of the `opts` object:\r\n\r\nhttps://github.com/shipharbor/merry/blob/master/index.js#L22\r\n\r\nand the only way to pass a port to the component is when calling the `listen` method:\r\n\r\nhttps://github.com/shipharbor/merry/blob/master/index.js#L64\r\n\r\nprobably the constructor should store the `env` object and use it if the `listen` method is invoked w/o arguments\r\n\r\n```javascript\r\nconst merry = require('merry');\r\n\r\nconst env = { PORT: 8080 };\r\nconst app = merry({ env });\r\n\r\napp.listen(process.env.PORT);\r\n```\r\nfrom the terminal\r\n\r\n```bash\r\nnode index.js\r\n// \"port\":8080\r\n\r\nPORT=1234 node index.js\r\n// \"port\":1234\r\n```\r\n\r\na possible solution could be:\r\n\r\n```javascript\r\nfunction Merry (opts) {\r\n  /* ... */\r\n\r\n  this._env = opts.env || {}\r\n}\r\n\r\nMerry.prototype.listen = function (port) {\r\n  if(port === undefined){\r\n    port = this._env.PORT\r\n  }\r\n\r\n  /* ... */\r\n}\r\n```\r\n\r\nlet me know what you think as I maybe miss something 😊 \r\nthanks,"},"comment":{"url":"https://api.github.com/repos/shipharbor/merry/issues/comments/305334018","html_url":"https://github.com/shipharbor/merry/issues/88#issuecomment-305334018","issue_url":"https://api.github.com/repos/shipharbor/merry/issues/88","id":305334018,"user":{"login":"mattiaerre","id":6423261,"avatar_url":"https://avatars0.githubusercontent.com/u/6423261?v=3","gravatar_id":"","url":"https://api.github.com/users/mattiaerre","html_url":"https://github.com/mattiaerre","followers_url":"https://api.github.com/users/mattiaerre/followers","following_url":"https://api.github.com/users/mattiaerre/following{/other_user}","gists_url":"https://api.github.com/users/mattiaerre/gists{/gist_id}","starred_url":"https://api.github.com/users/mattiaerre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattiaerre/subscriptions","organizations_url":"https://api.github.com/users/mattiaerre/orgs","repos_url":"https://api.github.com/users/mattiaerre/repos","events_url":"https://api.github.com/users/mattiaerre/events{/privacy}","received_events_url":"https://api.github.com/users/mattiaerre/received_events","type":"User","site_admin":false},"created_at":"2017-05-31T22:17:36Z","updated_at":"2017-05-31T22:17:36Z","body":"hi @lrlna and thanks for your reply, I like this API and thanks for the PR as well; I've left some comments 😉 "}}
{"actor":{"display_login":"mattiaerre"}}