miki2826 / botly

Simple Facebook Messenger Bot API
http://developers.askhaley.com
MIT License
92 stars 34 forks source link

FB_URL hardcoded - can it be configurable for better testability? #47

Closed umnagendra closed 6 years ago

umnagendra commented 6 years ago

PROBLEM

In Botly.js, the URL to graph.facebook.com is hard-coded.

const FB_URL = 'https://graph.facebook.com/v2.6/';
const FB_MESSENGER_URL = `${FB_URL}/me/messages`;

Apps (such as mine) using this module are not able to do functional automation testing using a facebook simulator because the hardcoded URLs always force all interactions towards graph.facebook.com.

PROPOSAL

Without breaking compatibility, can we optionally override this URL using process.env? Something like this:

const FB_URL = process.env.FB_URL || 'https://graph.facebook.com/v2.6/';

This way, apps that want to plug in a simulator for tests can do so without breaking other apps that are already using this module?

I have the change ready and working. I can raise a PR for this.

umnagendra commented 6 years ago

Thank you @miki2826 for the super-quick response, and the fix! Cheers!