Skip to content

Commit ef3d14e

Browse files
committed
Create Boards endpoint
1 parent 60712b4 commit ef3d14e

13 files changed

+233
-90
lines changed

Docker/Horse/Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM hashload/delphi-dev:10.3.1-rio
2+
RUN apt-get -y update \
3+
&& apt-get -y install \
4+
libpq5 \
5+
&& ln -s /usr/lib/x86_64-linux-gnu/libpq.so.5 /usr/lib/x86_64-linux-gnu/libpq.so

KanbanaApi.dpr

+4-13
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,9 @@ program KanbanaApi;
66
uses
77
Horse,
88
Horse.Jhonson,
9-
Controllers.Users in 'Src\Controllers\Controllers.Users.pas',
10-
Providers.Mongo in 'Src\Providers\Providers.Mongo.pas',
11-
ugar.connection.Imp in '..\ugar\src\ugar.connection.Imp.pas',
12-
ugar.db.mongo.Enum in '..\ugar\src\ugar.db.mongo.Enum.pas',
13-
ugar.db.mongo.Func in '..\ugar\src\ugar.db.mongo.Func.pas',
14-
ugar.db.mongo.Imp in '..\ugar\src\ugar.db.mongo.Imp.pas',
15-
ugar.db.mongo.internals in '..\ugar\src\ugar.db.mongo.internals.pas',
16-
ugar.db.Mongo in '..\ugar\src\ugar.db.Mongo.pas',
17-
ugar.db.mongo.Protocol in '..\ugar\src\ugar.db.mongo.Protocol.pas',
18-
ugar.db.mongo.protocol.Types in '..\ugar\src\ugar.db.mongo.protocol.Types.pas',
19-
ugar.db.mongo.Query in '..\ugar\src\ugar.db.mongo.Query.pas',
20-
Ugar in '..\ugar\src\Ugar.pas';
9+
Controllers.Boards in 'Src\Controllers\Controllers.Boards.pas',
10+
Providers.Connection in 'Src\Providers\Providers.Connection.pas' {ProviderConnection: TDataModule},
11+
Services.Boards in 'Src\Services\Services.Boards.pas' {ServiceBoards: TDataModule};
2112

2213
var
2314
App: THorse;
@@ -29,7 +20,7 @@ begin
2920
try
3021
App.Use(Jhonson);
3122

32-
Users(App);
23+
Boards(App);
3324

3425
App.Start;
3526
finally

KanbanaApi.dproj

+24-25
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<DCC_K>false</DCC_K>
5555
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
5656
<SanitizedProjectName>KanbanaApi</SanitizedProjectName>
57-
<DCC_UnitSearchPath>D:\OneDrive\projects\hashload\kanbana-api\modules\horse\src\;D:\OneDrive\projects\hashload\kanbana-api\modules\ugar\src\;modules\grijjyfoundation;modules\grijjyfoundation\UnitTests\Tests;modules\.dcp;modules\.dcp;modules\horse\src;modules\.dcp;modules\.dcp;modules\jhonson\src;modules\.dcp;modules\.dcp;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
57+
<DCC_UnitSearchPath>D:\OneDrive\projects\hashload\kanbana-api\modules\horse\src\;D:\OneDrive\projects\hashload\kanbana-api\modules\ugar\src\;$(DCC_UnitSearchPath);modules\DataSetConverter4Delphi\src;modules\DataSetConverter4Delphi\unittest;modules\.dcp;modules\.dcp;modules\horse\src;modules\.dcp;modules\.dcp;modules\jhonson\src;modules\.dcp;modules\.dcp;modules\ragna\src;modules\.dcp;modules\.dcp</DCC_UnitSearchPath>
5858
</PropertyGroup>
5959
<PropertyGroup Condition="'$(Base_Linux64)'!=''">
6060
<DCC_UsePackage>RESTComponents;emsclientfiredac;DataSnapFireDAC;FireDACADSDriver;DatasnapConnectorsFreePascal;FireDACMSSQLDriver;inetdb;emsedge;FireDACIBDriver;dbexpress;IndyCore;dsnap;emsclient;DataSnapCommon;FireDACCommon;RESTBackendComponents;DataSnapConnectors;soapserver;bindengine;CloudService;FireDACOracleDriver;FireDACMySQLDriver;FireDACCommonODBC;FireDACCommonDriver;DataSnapClient;inet;IndySystem;FireDACDb2Driver;FireDACInfxDriver;FireDAC;emshosting;FireDACSqliteDriver;FireDACPgDriver;FireDACASADriver;FireDACTDataDriver;soaprtl;DbxCommonDriver;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;rtl;emsserverresource;DbxClientDriver;CustomIPTransport;bindcomp;dbxcds;FireDACODBCDriver;DataSnapIndy10ServerTransport;dsnapxml;dbrtl;IndyProtocols;FireDACMongoDBDriver;DataSnapServerMidas;$(DCC_UsePackage)</DCC_UsePackage>
@@ -100,18 +100,17 @@
100100
<DelphiCompile Include="$(MainSource)">
101101
<MainSource>MainSource</MainSource>
102102
</DelphiCompile>
103-
<DCCReference Include="Src\Controllers\Controllers.Users.pas"/>
104-
<DCCReference Include="Src\Providers\Providers.Mongo.pas"/>
105-
<DCCReference Include="..\ugar\src\ugar.connection.Imp.pas"/>
106-
<DCCReference Include="..\ugar\src\ugar.db.mongo.Enum.pas"/>
107-
<DCCReference Include="..\ugar\src\ugar.db.mongo.Func.pas"/>
108-
<DCCReference Include="..\ugar\src\ugar.db.mongo.Imp.pas"/>
109-
<DCCReference Include="..\ugar\src\ugar.db.mongo.internals.pas"/>
110-
<DCCReference Include="..\ugar\src\ugar.db.Mongo.pas"/>
111-
<DCCReference Include="..\ugar\src\ugar.db.mongo.Protocol.pas"/>
112-
<DCCReference Include="..\ugar\src\ugar.db.mongo.protocol.Types.pas"/>
113-
<DCCReference Include="..\ugar\src\ugar.db.mongo.Query.pas"/>
114-
<DCCReference Include="..\ugar\src\Ugar.pas"/>
103+
<DCCReference Include="Src\Controllers\Controllers.Boards.pas"></DCCReference>
104+
<DCCReference Include="Src\Providers\Providers.Connection.pas">
105+
<Form>ProviderConnection</Form>
106+
<FormType>dfm</FormType>
107+
<DesignClass>TDataModule</DesignClass>
108+
</DCCReference>
109+
<DCCReference Include="Src\Services\Services.Boards.pas">
110+
<Form>ServiceBoards</Form>
111+
<FormType>dfm</FormType>
112+
<DesignClass>TDataModule</DesignClass>
113+
</DCCReference>
115114
<BuildConfiguration Include="Release">
116115
<Key>Cfg_2</Key>
117116
<CfgParent>Base</CfgParent>
@@ -634,15 +633,15 @@
634633
<Operation>1</Operation>
635634
</Platform>
636635
</DeployClass>
637-
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
638-
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
639-
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
640-
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
641-
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
642-
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
643-
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
644-
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
645-
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
636+
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"></ProjectRoot>
637+
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"></ProjectRoot>
638+
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"></ProjectRoot>
639+
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"></ProjectRoot>
640+
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"></ProjectRoot>
641+
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"></ProjectRoot>
642+
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"></ProjectRoot>
643+
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"></ProjectRoot>
644+
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"></ProjectRoot>
646645
</Deployment>
647646
<Platforms>
648647
<Platform value="Linux64">True</Platform>
@@ -652,7 +651,7 @@
652651
</BorlandProject>
653652
<ProjectFileVersion>12</ProjectFileVersion>
654653
</ProjectExtensions>
655-
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
656-
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
657-
<Import Project="$(MSBuildProjectName).deployproj" Condition="Exists('$(MSBuildProjectName).deployproj')"/>
654+
<Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"></Import>
655+
<Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"></Import>
656+
<Import Project="$(MSBuildProjectName).deployproj" Condition="Exists('$(MSBuildProjectName).deployproj')"></Import>
658657
</Project>

Linux64/Debug/KanbanaApi

8.97 MB
Binary file not shown.
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
unit Controllers.Boards;
2+
3+
interface
4+
5+
uses
6+
Horse;
7+
8+
procedure Boards(App: THorse);
9+
10+
implementation
11+
12+
uses System.JSON, Ragna, Services.Boards;
13+
14+
procedure Boards(App: THorse);
15+
begin
16+
App.Post('/boards',
17+
procedure(Req: THorseRequest; Res: THorseResponse; Next: TProc)
18+
begin
19+
var Boards := TServiceBoards.Create;
20+
try
21+
var JSON: TJSONArray;
22+
23+
Boards
24+
.Post(Req.Body<TJSONObject>)
25+
.ToJson(JSON);
26+
27+
Res.Send(JSON);
28+
finally
29+
Boards.Free;
30+
end;
31+
end);
32+
33+
App.Get('/boards',
34+
procedure(Req: THorseRequest; Res: THorseResponse; Next: TProc)
35+
begin
36+
var Boards := TServiceBoards.Create;
37+
try
38+
var JSON: TJSONArray;
39+
40+
Boards
41+
.Get
42+
.ToJson(JSON);
43+
44+
Res.Send(JSON);
45+
finally
46+
Boards.Free;
47+
end;
48+
end);
49+
end;
50+
51+
end.

Src/Controllers/Controllers.Users.pas

-29
This file was deleted.
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
object ProviderConnection: TProviderConnection
2+
OldCreateOrder = False
3+
Height = 150
4+
Width = 215
5+
object FDConnection: TFDConnection
6+
Params.Strings = (
7+
'Database=kanbana'
8+
'User_Name=postgres'
9+
'Password=postgres'
10+
'DriverID=PG')
11+
ConnectedStoredUsage = [auDesignTime]
12+
LoginPrompt = False
13+
BeforeConnect = FDConnectionBeforeConnect
14+
Left = 80
15+
Top = 40
16+
end
17+
end
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
unit Providers.Connection;
2+
3+
interface
4+
5+
uses
6+
System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf,
7+
FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.ConsoleUI.Wait,
8+
Data.DB, FireDAC.Comp.Client, FireDAC.Phys.PG, FireDAC.Phys.PGDef;
9+
10+
type
11+
TProviderConnection = class(TDataModule)
12+
FDConnection: TFDConnection;
13+
procedure FDConnectionBeforeConnect(Sender: TObject);
14+
public
15+
constructor Create; reintroduce;
16+
end;
17+
18+
var
19+
ProviderConnection: TProviderConnection;
20+
21+
implementation
22+
23+
{%CLASSGROUP 'System.Classes.TPersistent'}
24+
{$R *.dfm}
25+
26+
constructor TProviderConnection.Create;
27+
begin
28+
inherited Create(nil);
29+
end;
30+
31+
procedure TProviderConnection.FDConnectionBeforeConnect(Sender: TObject);
32+
var
33+
Params: TFDPhysPGConnectionDefParams;
34+
begin
35+
Params := TFDPhysPGConnectionDefParams(FDConnection.Params);
36+
Params.UserName := GetEnvironmentVariable('DB_USER');
37+
Params.Password := GetEnvironmentVariable('DB_PASSWORD');
38+
Params.Database := GetEnvironmentVariable('DB_DATABASE');
39+
Params.Port := GetEnvironmentVariable('DB_PORT').ToInteger;
40+
Params.Server := GetEnvironmentVariable('DB_HOST');
41+
end;
42+
43+
end.

Src/Providers/Providers.Mongo.pas

-17
This file was deleted.

Src/Services/Services.Boards.dfm

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
inherited ServiceBoards: TServiceBoards
2+
OldCreateOrder = True
3+
Height = 309
4+
Width = 403
5+
inherited FDConnection: TFDConnection
6+
Connected = True
7+
end
8+
object Boards: TFDQuery
9+
Connection = FDConnection
10+
SQL.Strings = (
11+
'select '
12+
' boards.id,'
13+
' boards.name'
14+
'from boards')
15+
Left = 208
16+
Top = 56
17+
object BoardsId: TLargeintField
18+
AutoGenerateValue = arAutoInc
19+
FieldName = 'id'
20+
Origin = 'id'
21+
ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
22+
end
23+
object BoardsName: TWideStringField
24+
FieldName = 'name'
25+
Origin = 'name'
26+
Size = 255
27+
end
28+
end
29+
end

Src/Services/Services.Boards.pas

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
unit Services.Boards;
2+
3+
interface
4+
5+
uses
6+
System.SysUtils, System.Classes, Providers.Connection, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error,
7+
FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys,
8+
FireDAC.ConsoleUI.Wait, Data.DB, FireDAC.Comp.Client, FireDAC.Phys.PG, FireDAC.Phys.PGDef, FireDAC.Stan.Param,
9+
FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, FireDAC.Comp.DataSet, Ragna,
10+
System.JSON;
11+
12+
type
13+
TServiceBoards = class(TProviderConnection)
14+
Boards: TFDQuery;
15+
BoardsId: TLargeintField;
16+
BoardsName: TWideStringField;
17+
public
18+
function Get: TFDQuery;
19+
function Post(Board: TJSONObject): TFDQuery;
20+
end;
21+
22+
var
23+
ServiceBoards: TServiceBoards;
24+
25+
implementation
26+
27+
{%CLASSGROUP 'System.Classes.TPersistent'}
28+
{$R *.dfm}
29+
30+
{ TServiceBoards }
31+
32+
function TServiceBoards.Get: TFDQuery;
33+
begin
34+
Result := Boards
35+
.OpenUp;
36+
end;
37+
38+
function TServiceBoards.Post(Board: TJSONObject): TFDQuery;
39+
begin
40+
Result := Boards
41+
.New(Board)
42+
.OpenUp;
43+
end;
44+
45+
end.

boss.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"projects": [],
88
"dependencies": {
99
"github.com/hashload/horse": "^v1.6.4",
10-
"github.com/hashload/jhonson": "^1.0.2"
10+
"github.com/hashload/jhonson": "^1.0.2",
11+
"github.com/hashload/ragna": "^1.1.0"
1112
}
1213
}

0 commit comments

Comments
 (0)