Use platform types vs our own. Hook up NP via kbnServer.newPlatform.#39824
Use platform types vs our own. Hook up NP via kbnServer.newPlatform.#39824jfsiii merged 1 commit intoelastic:feature-integrations-managerfrom jfsiii:use-kbnserver-and-more-np
Conversation
rudolf
left a comment
There was a problem hiding this comment.
You could switch to only use CoreSetup and CoreStart from src/core/server. At some point you might require functionality that isn't provided in Core but will eventually be moved there (like SavedObjects) so then you could create an type like interface IntegrationsCoreSetup extends CoreSetup {...} to add these dependencies internal to your plugin until they become available.
| import { fetchList } from './registry'; | ||
| import { routes } from './routes'; | ||
|
|
||
| export interface CoreSetup { |
There was a problem hiding this comment.
You can also pull in CoreSetup from src/core/server
| // `kbnServer.newPlatform` has important values | ||
| const kbnServer = (server as unknown) as KbnServer; | ||
| const initializerContext: PluginInitializerContext = {}; | ||
| const coreSetup: CoreSetup = kbnServer.newPlatform.setup.core; |
There was a problem hiding this comment.
👍 now you're using the actual new platform instead of approximating it with a shim.
| constructor(initializerContext: PluginInitializerContext) {} | ||
| public setup(core: CoreSetup) { | ||
| const { route } = core.http; | ||
| const { server } = core.http; |
There was a problem hiding this comment.
http.server is there for backwards compatibility/legacy, but you can also switch to http.registerRouter to only rely on new platform functionality.
There was a problem hiding this comment.
just a reminder that route handler interfaces is not stabilized yet. it will be exposed once we implement #39767
jasonrhodes
left a comment
There was a problem hiding this comment.
lgtm! exciting to see this new plugin stuff shape up


Summary
Use
KbnServerso we get NP features inkbnServer.newPlatform.Currently using for calling the plugin
setupwith the NPCoreStartofkbnServer.newPlatform.setup.core