Um framework inspirado no NestJS para Delphi com o poderoso Horse!
Sinta-se encorajado a abrir issues, enviar pull requests ou compartilhar ideias para melhorar este projeto. Toda ajuda é bem-vinda!
try
TNest4DApplication.NewApplication(TAppModule,
procedure(app: TNest4DApplication)
begin
app.Start();
end);
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
uses
Nest4D.Interfaces;
type
TAppModule = Class(TInterfacedObject, IN4DModule)
public
function Imports: TArray<TClass>;
function Services: TArray<TClass>;
function Controllers: TArray<TClass>;
End;
implementation
uses
app.controller,
app.service;
{ TAppModule }
function TAppModule.Controllers: TArray<TClass>;
begin
Result := [TAppController];
end;
function TAppModule.Imports: TArray<TClass>;
begin
Result := [];
end;
function TAppModule.Services: TArray<TClass>;
begin
Result := [TAppService];
end;
uses
System.Json,
Nest4D.Attributes,
app.service;
type
[N4DController('/api')]
TAppController = Class
private
FAppService: TAppService;
public
[N4DRoute(Get, '')]
function getApi: TJsonObject;
constructor Create(AAppService: TAppService);
End;
implementation
{ TAppController }
constructor TAppController.Create(AAppService: TAppService);
begin
FAppService := AAppService;
end;
function TAppController.getApi: TJsonObject;
begin
Result := TJSONObject.Create.AddPair('message', 'Hello, World!');
end;