Expose JS files in Public folder

What if scripts added in public folder could be exposed as API’s?

Let me elaborate on my thoughts. A lot of coding issues will end up in talking to WIX from other systems in the future. One way to make this happen without that much of a deal (I guess, don’t have a clue) would be to expose Javascript files under the public folder.

If I create a file called api.news.js the system will automatically handle that because it has the api. in the filename. After saving this file I have a new endpoint on my site reachable from:

https://mysite.com/api/news/

I could then post stuff to that address and get the contents using…

let jsonBody = json_decode("wix://input");

That code would get all posted into a JSON decoded string and then I can insert that into collections, work with it in anyway using WIX code and return what ever I need to return.

This way I can expose how many API’s I wan’t by just adding files, I don’t have to expose my whole Data Collections or in anyway do anything else.

Add a file in a certain naming convention and then rock n roll.

I am going to interject off subject a bit. Where is a good example of implementing public.js files? In the cascading form examples, it notes the use of such, but does not show example of what the usStates public.js file is. For a newbie, it really is a stone wall.

What code is being created for this. It would go along way to helping explain by showing the example fully out as to code and the public code(s) associated with it