parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.95k stars 4.78k forks source link

feat: add config to request standard object and dependency middleware implementation #8479

Open Moumouls opened 1 year ago

Moumouls commented 1 year ago

New Feature / Enhancement Checklist

Current Limitation

No way to leverage inversion of control/dependency injection properly for each request

Feature / Enhancement Description

Parse Server is build following Hexagonal software architecture, and originally heavily use inversion of control patterns, that allow parse server to be easily extendable and customizable.

Currently there is no way to add some custom controllers with request granularity to the parse config. Following the Parse Server DNA, developers should be able to modify config per request, mutate config object if needed. Then the config is forwarded to each Parse Server hooks, and even in each Parse Server GraphQL resolvers.

Example Use Case

See the linked PR

8480

In my company we already use this feature from my fork to implement elegantly custom controllers related to request data (user, keys etc...), and for example a "FeatureFlagController".

Alternatives / Workarounds

No workarounds

3rd Party References

parse-github-assistant[bot] commented 1 year ago

Thanks for opening this issue!

dblythy commented 1 year ago

You can get and set the config at the moment with the global property Parse.Server, which will return the current config.

Is this related to #8448?

Moumouls commented 1 year ago

Not related @dblythy the set and get config is a singleton implementation pattern. With some limitations.

Her it's a inversion of control, dependency injection that allow to modify, overwrite the config for each request just before the request is forwarded to the parse server engine.

This kind of pattern allow: