{"action":"opened","issue":{"url":"https://api.github.com/repos/strongloop/loopback-next/issues/1967","repository_url":"https://api.github.com/repos/strongloop/loopback-next","labels_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1967/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1967/comments","events_url":"https://api.github.com/repos/strongloop/loopback-next/issues/1967/events","html_url":"https://github.com/strongloop/loopback-next/issues/1967","id":376806212,"node_id":"MDU6SXNzdWUzNzY4MDYyMTI=","number":1967,"title":"Allow extensions to contribute static assets","user":{"login":"bajtos","id":1140553,"node_id":"MDQ6VXNlcjExNDA1NTM=","avatar_url":"https://avatars1.githubusercontent.com/u/1140553?v=4","gravatar_id":"","url":"https://api.github.com/users/bajtos","html_url":"https://github.com/bajtos","followers_url":"https://api.github.com/users/bajtos/followers","following_url":"https://api.github.com/users/bajtos/following{/other_user}","gists_url":"https://api.github.com/users/bajtos/gists{/gist_id}","starred_url":"https://api.github.com/users/bajtos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bajtos/subscriptions","organizations_url":"https://api.github.com/users/bajtos/orgs","repos_url":"https://api.github.com/users/bajtos/repos","events_url":"https://api.github.com/users/bajtos/events{/privacy}","received_events_url":"https://api.github.com/users/bajtos/received_events","type":"User","site_admin":false},"labels":[{"id":744761240,"node_id":"MDU6TGFiZWw3NDQ3NjEyNDA=","url":"https://api.github.com/repos/strongloop/loopback-next/labels/Extensions","name":"Extensions","color":"fcc53a","default":false},{"id":817780663,"node_id":"MDU6TGFiZWw4MTc3ODA2NjM=","url":"https://api.github.com/repos/strongloop/loopback-next/labels/REST","name":"REST","color":"fcc53a","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-02T13:17:23Z","updated_at":"2018-11-02T13:17:23Z","closed_at":null,"author_association":"MEMBER","body":"While working on self-hosted API Explorer as a standalone extension (see https://github.com/strongloop/loopback-next/pull/1957), we discovered a missing feature: how can extensions like API Explorer contribute static assets?\r\n\r\n```ts\r\nexport class ExplorerComponent implements StaticComponent {\r\n   staticAssets = [\r\n     {\r\n       path: '/explorer1',\r\n       rootDir: './public', //path.resolve(__dirname, '../../../explorer'),\r\n       options: {},\r\n     },\r\n   ];\r\n }\r\n```\r\n\r\nThe tricky question to answer: what part of LB should process `staticAssets` provided by components? It cannot be done by `Application` and/or `mountComponent` in `@loopback/core`, because static assets are REST-specific and don't make sense in GraphQL applications (for an example). \r\n\r\nConsider also the following example we need to support:\r\n\r\n```ts\r\nconst app = new Application();\r\napp.component(RestComponent);\r\napp.component(ExplorerComponent);\r\n```\r\n\r\nA more subtle problem to address (ideally as part of this work): how can an extension (e.g. ExplorerComponent) declare a dependency on another extension (e.g. RestComponent)? Consider the following example - ideally the app should throw an error because the API Explorer cannot be used on non-REST apps:\r\n\r\n```ts\r\nconst app = new Application();\r\napp.component(ExplorerComponent);\r\n```\r\n"}}
{"actor":{"display_login":"bajtos"}}