Auto Tables for RAD Server is a client server solution which auto generates a REST API client/server/OpenAPI for your databases. The sample application and database that comes Auto Tables for RAD Server is called Logger and uses InterBase. You can swap out InterBase for any other database supported by FireDAC. I went ahead and generated the Logger sample project in the Auto Tables Editor and it is provided with this post. The client project should run on Android, IOS, OSX, Windows, and Linux (through FMXLinux). The server should run on Windows and Linux but has only been tested on Windows. I hooked up the LiveBindings in the client to some TStringGrids and some buttons to execute the REST API calls. There are three REST endpoints which are correspond to GET POST and DELETE. GetLogger for requesting the list of records from the Logger database table. PostLogger for posting a new record into the Logger database table. And finally DeleteLogger for deleting a recording out of the Logger database table. All of the REST API are made to the included RAD Server project. As you will see in the RAD Server project the endpoints are contained within a TFDMemTable. The Auto Tables Editor also generates a FireDAC JSON file which can be loaded into the TFDMemTable inside the sample RAD Server project. This allows you to make changes to the REST API endpoints without having to entirely re-generate the server project. As you will see in the sample the documentation for the REST API is provided via Swagger-UI in the Docs directory of the sample. Here is the entire source code that I added to the sample project after the auto generation of the client and server were complete.
// // // procedure TMainForm.GetStringGridSelChanged(Sender: TObject); begin DeleteIdEdit.Text := GetStringGrid.Cells[0,GetStringGrid.Selected]; end; procedure TMainForm.GetBTNClick(Sender: TObject); begin AutoTablesClientDM.getloggerExecute; end; procedure TMainForm.PostBTNClick(Sender: TObject); begin AutoTablesClientDM.postloggerExecute; GetBTNClick(Self); end; procedure TMainForm.DeleteBTNClick(Sender: TObject); begin if DeleteIdEdit.Text<>'' then begin AutoTablesClientDM.deleteloggerExecute(DeleteIdEdit.Text); DeleteMemo.Lines.Append('Delete ' + DeleteIdEdit.Text + ' sent successfully!'); DeleteIdEdit.Text := ''; GetBTNClick(Self); end; end;
Download the full source for the Auto Tables For RAD Server Sample Logger solution.
1 Comment