agnelvishal / Condense.press

GNU General Public License v3.0
12 stars 25 forks source link

Use rest api instead of sql statements. #Hacktoberfest #23

Open agnelvishal opened 5 years ago

agnelvishal commented 5 years ago

As of now, mysql query is used in the php file to interact with the database. A rest api is available but has not been used in the php file. Could someone help?

agnelvishal commented 5 years ago

The rest api is available at https://github.com/agnelvishal/Condense.press/tree/master/rest-api

devdadmax commented 5 years ago

pull request has been submitted.

agnelvishal commented 5 years ago

Hello @LegacyStackCrash Will it be possible to use ajax instead of curl?

devdadmax commented 5 years ago

@agnelvishal it is possible to produce the same functionality using ajax instead of curl. However I would highly recommend a small refactor if you want to move over to ajax. Additionally some other things to consider is that by moving to an AJAX call you will now be subject to CORS. While this is not an issue when your client and server are on the same host. It can become a little confusing if you choose to serve your server from say "example.com" but then serve your client page from "example2.com".

agnelvishal commented 5 years ago

By refactor, is it meant that the code for high charts and cards have to be moved from server to client?

devdadmax commented 5 years ago

In this case that is correct. Currently your HTML and JS is intertwined with your PHP which is okay for the approach for the way it currently works. However you would not really want to leave the extra overhead of PHP on the client side rendering if you are going to utilize ajax to request the data from the front end.

agnelvishal commented 5 years ago

So in this case ajax is a bad idea?

devdadmax commented 5 years ago

Not necessarily, this is more or less a design decision on your part to determine if you would prefer your server to do the work on gathering data or if you want your client's browser to do the work to gather the data. However if you want to move to your client gathering data(ajax) a small refactor(code rewrite) would be beneficial to your project as you gain no benefit from your db.php once you move to using an Ajax call.

I see that you also have an issue open for refactoring to VueJS. When this issue is picked up would be a good time to refactor the way your client is served content from curl to an ajax call.