Well, I have implemented a list of resources that work properly after API key authorization.
I only used onApplicationStart and onTaffyRequest as advised in github wiki pages of Taffy.
I brought some helper functions (from actual web application) into the Taffy API. I just created a third component appInterface.cfc with those helper functions within the API directory and initialized that component in onApplicationStart and put stored in application.appInterface variable to further use within the API resources.
Well that actually worked, but now that the API revolves around the original web application and is intended to serve the data from that application, I wanted to include all those functions from the web application with all the queries and other stuff. I have dozens of functions in that application written separately in a couple of .cfm files (yes, the core of that web application is not based on components, hence all those functions are available via functions1.cfm, functions2.cfm, etc.)
Now I don't want to write those functions again in my API, but I want to include those function files (those .cfm files) within the API. So that I could directly interact with those functions from within the API. Other reason is that the web application is a work in progress and is always being updated with more features. I don't want to make all those changes in the API too. That's why it's important for me to include those functions in the API so that I can make use of them within the API resources.
I tried by simply including those functions in onTaffyRequest like below
include "/helper-functions.cfm";
include "/app-functions.cfm";
It actually worked when used the authorization key verification function from the
helper-functions.cfm within the
Application.cfc of Taffy API.
But none of those functions were available in the API resources.
Then I thought about including that helper-functions.cfm within the resource someCollection.cfc, but it threw an exception that "Routines cannot be declared more than once."
Means it was actually identifying that those helper functions were already available to this resource. But when I try to use any of those functions in that resource. it gives the Variable undefined error.
So just wanted to know, how should I do it the right way?
If this is even possible?
Thank you
Regards