Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nest4D

Nest4D

Um framework inspirado no NestJS para Delphi com o poderoso Horse!


Este repositório está aberto para contribuições!

Sinta-se encorajado a abrir issues, enviar pull requests ou compartilhar ideias para melhorar este projeto. Toda ajuda é bem-vinda!

Ponto de entrada

  try
    TNest4DApplication.NewApplication(TAppModule,
      procedure(app: TNest4DApplication)
      begin
        app.Start();
      end);
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;

Modulo

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;

Controller

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;

About

Nest4D: Um framework inspirado no NestJS para Delphi com o poderoso Horse!

Resources

Stars

11 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages