adonisjs/ally

Set/Config `set baseUrl` to drivers

kevyworks opened this issue · 9 comments

Hi, may I request if you can add a set baseUrl and also get configuration options to services.ally.<driver>.baseUrl ?

May I know why the baseUrl has to be configurable?

Hi @thetutlage for flexibility purposes if we can? and, by the way do you have a sample code or documentation on how to add ally driver just so we can extend existing and create our own?

But if the facebook base url is xyz, then how/why you want to change it?

@thetutlage Here is a pseudocode below

config/services.js

facebook: {
   baseUrl: 'https://graph.facebook.com/v3.5'
}

Controller / inline

  ...
  const fb_url = await Someclient.getFacebookApiUrl()
  let url = await ally.driver('facebook')
    .setBaseUrl(fb_url)
    .getRedirectUrl()
  ...

My concern is if v2.1 is for v2.10 and not v2.11 then our code will fail. Clear scenario will happen is for example; if offered api versions are: v2.1, v2.11, v2.12, v2.2, v2.21, and the feature you want is at a specific v2.2 only then what do we do?

Yeah but updating the base url only will not help.

So let's say you want to use a different version and now the response returned for that version is different from what ally expect, then it will simply fail.

@thetutlage I see, so I guess we need to add an easy way to extend a new driver to ally?

Something like:

services.js

module.exports = {
  ally: {
    custom: [{
      name: 'facebookV22',
      driver: 'App/Libraries/Drivers/FacebookV22',
      ...
    }],
    facebook: {
      ...
    },
    google: {
      ...
    },
    ...
  }
}

Would that be a valid feature? currently I guess I can do it on hooks to register new, but I haven't tried it yet.

But why do you want to use a different version from Facebook and specifically if you can point me to the feature you are looking for from Facebook API?

hi @tutlage this is just a scenario. just making the library a bit flexible in most case. I know you like to make the library clean and its good.

The extending capabilities has to be uniform across the code base. So IoC container gives a simple way to extend any binding ( which exposes itself to be extended ) using Ioc.extend method.

For now. I am not in favor of changing anything in the codebase, unless something major is preventing you from using this library.