{"action":"created","issue":{"url":"https://api.github.com/repos/donejs/done-ssr-middleware/issues/11","repository_url":"https://api.github.com/repos/donejs/done-ssr-middleware","labels_url":"https://api.github.com/repos/donejs/done-ssr-middleware/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/donejs/done-ssr-middleware/issues/11/comments","events_url":"https://api.github.com/repos/donejs/done-ssr-middleware/issues/11/events","html_url":"https://github.com/donejs/done-ssr-middleware/issues/11","id":148820644,"number":11,"title":"Support alternative system.configs","user":{"login":"marshallswain","id":128857,"avatar_url":"https://avatars.githubusercontent.com/u/128857?v=3","gravatar_id":"","url":"https://api.github.com/users/marshallswain","html_url":"https://github.com/marshallswain","followers_url":"https://api.github.com/users/marshallswain/followers","following_url":"https://api.github.com/users/marshallswain/following{/other_user}","gists_url":"https://api.github.com/users/marshallswain/gists{/gist_id}","starred_url":"https://api.github.com/users/marshallswain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marshallswain/subscriptions","organizations_url":"https://api.github.com/users/marshallswain/orgs","repos_url":"https://api.github.com/users/marshallswain/repos","events_url":"https://api.github.com/users/marshallswain/events{/privacy}","received_events_url":"https://api.github.com/users/marshallswain/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-16T05:50:50Z","updated_at":"2016-04-17T19:16:22Z","closed_at":null,"body":"I'd like to come up with an API to support alternative configurations.  This would be useful when you want to SSR-load a different main for non-authenticated/public users, for example.  I'd like to see something where you could provide keyed configs in an object like this:\r\n\r\n```js\r\nvar configs = {\r\n  public: {\r\n\t  config: process.cwd() + '/public/package.json!npm',\r\n\t  bundle: 'feathers-chat/public.stache!done-autorender',\r\n\t  liveReload: true\r\n  },\r\n  app: {\r\n\t  config: process.cwd() + '/public/package.json!npm',\r\n\t  liveReload: true\r\n  }\r\n};\r\n```\r\n\r\nI'm thinking that this would create a renderer for each config, and render would actually be an object keyed the same way, so you could provide a function to select which renderer.\r\n\r\n```js\r\nselectRenderer(req){\r\n  if (req.hasValidCookie) {\r\n    return 'app';\r\n  } else {\r\n    return 'public';\r\n  }\r\n}\r\n```\r\n\r\nThen the code here could be modified to look like this:\r\n```js\r\nreturn function (req, res, next) {\r\n  var stream = render[selectRenderer(req)](req);\r\n  stream.on(\"error\", next);\r\n  stream.pipe(res);\r\n  res.type(\"html\");\r\n};\r\n```\r\n\r\nI think this API would allow flexibility to do as many alternative configurations as desired.\r\n\r\nBut now the big question is, can we make it work so that it conditionally loads a different bundle from the package.json?"},"comment":{"url":"https://api.github.com/repos/donejs/done-ssr-middleware/issues/comments/211089710","html_url":"https://github.com/donejs/done-ssr-middleware/issues/11#issuecomment-211089710","issue_url":"https://api.github.com/repos/donejs/done-ssr-middleware/issues/11","id":211089710,"user":{"login":"justinbmeyer","id":78602,"avatar_url":"https://avatars.githubusercontent.com/u/78602?v=3","gravatar_id":"","url":"https://api.github.com/users/justinbmeyer","html_url":"https://github.com/justinbmeyer","followers_url":"https://api.github.com/users/justinbmeyer/followers","following_url":"https://api.github.com/users/justinbmeyer/following{/other_user}","gists_url":"https://api.github.com/users/justinbmeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/justinbmeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinbmeyer/subscriptions","organizations_url":"https://api.github.com/users/justinbmeyer/orgs","repos_url":"https://api.github.com/users/justinbmeyer/repos","events_url":"https://api.github.com/users/justinbmeyer/events{/privacy}","received_events_url":"https://api.github.com/users/justinbmeyer/received_events","type":"User","site_admin":false},"created_at":"2016-04-17T19:16:22Z","updated_at":"2016-04-17T19:16:22Z","body":"Why a separate package.json?\n\nSent from my iPhone\n\n> On Apr 17, 2016, at 1:47 PM, Marshall Thompson <notifications@github.com> wrote:\n> \n> The main app is much simpler when it can assume that it already has valid auth. I'm using progressive enhancement on the public-facing app, so it assumes no auth until it has a chance to check the validity of the token on the client.\n> \n> The only way I can see this working currently is to provide a separate package.json with a different main.\n> \n> —\n> You are receiving this because you commented.\n> Reply to this email directly or view it on GitHub\n> \n"}}