Skip to content

Improve Extension authoring #953

@bajtos

Description

@bajtos

List of issues in the current design of Extensions:

  • Writing an extension class requires a lot of hand-written glue. The developer has explicitly list all controllers, bindings, etc. they want to add to the app. We should have a conventional bootstrapper that can scan filesystem and discover entities to add to the app automatically. Ideally, most of the conventions should be same for applications and extensions, so that LoopBack users have only one set of conventions to learn, and the bootstrapper package has only one set of conventions to implement.

  • Adding support for new type of entities that can be contributed by extensions requires changes in several places. For example, we already have API for binding classes (app.bind('foo').toClass(Foo)), but components cannot leverage it until app.component() is updated to support it as well.

  • Even though it's easy for a component to contribute Providers for DI, the extension cannot control binding settings like scope (SINGLETON), tags, etc.

I think we should step back to the drawing board, build/update the requirements (a list of things extensions typically want to accomplish), and come up with the best solution that will support these requirements while making developer experience superb.

More requirements to keep in mind:

  1. The ability to expose an extension point to allow customization of a service and fall back to a default implementation. For example, a user management component by default uses bcrypt for password hashing but it should allow an optional external binding for the hashing function.

  2. The ability to organize artifacts as extension points/extensions, for example, bootstrapper -> booters, authenticator -> strategies, rest -> servers, even app -> components. The extension point should be able to depend on a list or map of extension instances for delegation. Each extension point and extension should be able to receive corresponding configurations.

  3. The ability to maintain isolated and connected contexts for an app, a component, or an extension point.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions