8000 Asynchronous app initialization and setup improvements · Issue #2500 · feathersjs/feathers · GitHub
[go: up one dir, main page]

Skip to content

Asynchronous app initialization and setup improvements #2500

@daffl

Description

@daffl

PR #2255 adds an asyncronous app.setup and service.setup which can be used with new hooks. However, when working with @marshallswain we noticed that this is still not ideal when configuring your application. For example the MongoDB service needs the asynchronous model in the configure function before its setup method is called. We are now looking at adding the following improvements:

  • app.configure should allow async functions. They will run in the order app.configure is called and only when the previous function returns. If there is any asynchronous app.configure function, await app.setup() or app.listen() must be called before any services (calling app.service(name)) can be used.
  • As an additional improvement and to avoid having the app in an unexpected state (e.g. in tests), if any service implements a setup method, await app.setup() or app.listen() must also be called before any services (calling app.service(name)) can be used.

Both changes will work compatible with existing applications, specifically we wanted to avoid having to unnecessarily call app.setup on client side Feathers apps.

Related to #509 and #853

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0