Description
It becomes evident that the extensibility of parse-server will be a core element of the server architecture.
Leveraging npm, it would be very simple and efficient to setup servers with custom adapters without the need of writing code.
I am personally looking for 'configuring' standalone parse-server instead of maintaining an express app that would serve the parse-server alongside the rest of my web app.
I'm opening the issue here to discuss this architecture.
I suggest the following proposal:
- Each extensible part of the server should be implemented through an adapter.
- On the configuration object (args) we should be able to support adapters as module names.
- On the configuration object, we should be able to pass adapter options.
example:
Let's say someone implemented parse-server-sendgrid-emailadapter
and made it available on npm.
the configuration Object would look like:
{
appId: "AppID",
EmailAdapter: "parse-server-sendgrid-emailadapter",
options: {
"parse-server-sendgrid-emailadapter": { /*specific options for the module*/}
}
}
in EmailAdapter:
...
setAdapter: function(adapter) {
if (typeof adapter === "function") {
_adapter = adapter;
} else if (typeof adapter === "string") {
_adapter = require(adapter);
}
}
...
setOptions: function(options) {
if (typeof _adapter.setOptions === "function" ){
_adapter.setOptions(options);
}
}
For each adapter type, we would just have to provide the base API to conform to.
The developer of the module should provide an optional setOptions if the module support options.
For example the options for the mail adapter could be template URL's etc...
Thoughts @gfosco, @drew-gross, @nlutsenko ?