Remodel REST API for Organization and Manageability; and use JSON format for readability
License and Copyright Notice
By submitting this issue or commenting on this issue, or contributing any content to this issue, you certify under the Developer Certificate of Origin that the content you post may be licensed under GPLv3 (for code) or CC-BY-SA 4.0 International (for non-code content).
What is the goal or the problem, and why is it important?
The goal is to redo the RESTful API for the PlaceOrderModule. Redo will be beneficial because the redone api will use JSON format. As per the research I did, JSON is the most widely used data format which is easier to read compared to xmlhttp. This will be helpful for modules requesting GET requests as it will be easier to process the data. The current approach is done perfectly for POST requests, but I see no traces for PATCH or DELETE. The GET requests, as said, uses a different format which is xmlhttp (harder to read or process). In addition, it is beneficial to the current and future developers who might work on this module to find and use the RESTful API effortlessly.
How are you going to achieve the goal or solve the problem?
This will be achieved by remodifying the existing files that have traces of RESTful API. Some of the files might have to be done again (from scratch). If we try to organize or modify the RESTful API in the current state, there is more chances of it breaking something. That would take a lot of time troubleshooting and fixing. The data output format will change to application/JSON. The methods created would be GET, POST, and PATCH as they have been identified as the required request methods for all the modules (including PlaceOrderModule). The testing of the REST API will be done using Postman.
What will be produced as a result of this effort and where will it live on GitLab?
As a result, a complete (Only required requests will be available) RESTful API for the PlaceOrderModule will be produced. This will live on the Backend folder of the PlaceOrderModule. The file structure will be list in the outcomes of this ticket.
Give a justification of weight or due date.
This issue is assigned, 8, which means it would take a weeks worth of work. The weight has been assigned considering redoing the RESTful API from scratch and getting it to work with testing.
Who will do it, and what will they do?
@np370688 is responsible for this task and will be remodeling the RESTful API.
What was the outcome?
The API was created with the new Order model. The project was organized by putting all the api routes in the routes folder. In our case, currently, it is only "orders". The default route path used is /api/orders/.... The routes created are to:
- GET Introduction Page (/api)
- POST Add a order (/post)
- GET Get all orders (/get)
- GET Get a specific order by ID (/get/:orderID)
- GET Get all orders place by a specific email (user) (/get/email/:emailID)
- GET Get all orders placed on a exact given date and time (/get/date/:orderDate)
- DELETE Delete a specific order by ID (/delete/:orderID)
JSON format can be implemented with the HTML header, which has nothing to do with the api request. If need to view/test the Backend, Firefox has inbuilt tools to convert the default API format to JSON. Moreover, different module creating a get request will receive the data in the format they have requested or might get the data in default format and change it later depending on how the requester wants to treats their data.