You are not logged in.
Pages: 1
I've uploaded some files for creating TMS WebCore/mORMot clients to:
https://github.com/SigmaSciences/mORMot-Web
It still needs a lot of testing and has missing functionality (I only use interface and method-based service from Web clients), but will hopefully be useful. I use mORMot 2 exclusively so haven't tested with v1. Pull requests welcome, though drop me an email (@gmail) with any suggestions (rlsdevine).
Cheers, Bob
Offline
Great work!
The remote ORM part is not needed for sure. It is not safe enough to be published directly.
Interface based services is the way to go, for any serious and efficient service.
The only missing feature is IMHO the template to generate the client code directly from the server.
One question: why use an external sha256.js ? has the mormot/pascal version any bug?
Online
Thanks Arnaud :-)
>why use an external sha256.js
When I started I couldn't get the mormot version to work, and was also learning about using external JS libraries in WebCore. I eventually figured out that I was picking up the wrong sh0 so restored the mormot code. I left the JS option in as an example of using an external library, but the default is the mormot code.
I'll need to learn a bit about Mustache but will try and find some time for the template soon.
Cheers, Bob
Offline
Hi @rdevine
I create Pull request
-Some small changes to be Pas2JS compatible without TMS Web Core
-Calculator service add code export wrappers and add procedure with 2 var params for testing
-Pas2JS Template in Template folder. Generated code mORMotPas2JsClient.pas is used in Pas2JSTest without any change
http://localhost:888/root/wrapper
-Pas2JSTest Demo
-Async and Sync calls works
I tested only on FPC and Pas2JS, not in Delphi or TMS Web Core
My fork: https://github.com/TTomas/mORMot-Web
Last edited by ttomas (2024-03-11 15:07:19)
Offline
Thank you! I've been meaning to get back to it and, e.g., sort out templates but it's been working great for me as-is so it keeps slipping down the list :-) I should find some time later in the week to test with WebCore before merging - thanks again.
Cheers, Bob
Offline
@ab, I create pull request
@rdevine, I update pull request
This type of interface is tested
TSex = (cMale, cFemale);
TCat = packed record
Name: RawUtf8;
Sex: TSex;
Birthday: TDateTime;
end;
TCatDynArray = array of TCat;
TCat3Array = array[0..2] of TCat;
TPeople = packed record
FirstName: RawUtf8;
LastName: RawUtf8;
Sex: TSex;
Birthday: TDateTime;
Cat: TCat;
CatNested: packed record
Name: RawUtf8;
Sex: TSex;
Birthday: TDateTime;
end;
Cat3: TCat3Array;
Cats: TCatDynArray;
CatsNested: array of TCat;
end;
ICalculator = interface(IInvokable)
['{9A60C8ED-CEB2-4E09-87D4-4A16F496E5FE}']
function Add(n1, n2: integer): integer;
function ArrayValue(const arrJSON: RawUtf8; ix: integer): variant;
function CountArray(const jsn: RawUtf8): integer;
function SumArray(const jsn: RawUtf8): double;
procedure FullName(const aFirstName, aLastName: RawUtf8;
var aFullName: RawUtf8; var aSize: integer);
function CatIsMale(const aCat: TCat): Boolean;
function GetCat: TCat;
function GetPeople(aId: integer; var aPeople: TPeople): Boolean;
function AddPeople(const aPeople: TPeople): integer;
function AddCat2People(const aCat: TCat; var aPeople: TPeople): boolean;
end;
With this changes created client need only 2 manual changes, move array types before TPeople record and Replace All nested type names with correct type name.
In https://github.com/TTomas/mORMot-Web/tr … Pas2JSTest you can view context.json and exported client mORMotPas2JsClientExport.pas and edited mORMotPas2JsClient.pas.
I try version without helper record/array function, In GetPeople onSuccess to use
onSuccess(TPeople(res[0]),Boolean(res[1]));
For simple types we can use this casting, but Birthday TDateTime field will be corrupt in pas2js. After this type of casting this field is no longer TDateTime (double/Number) but String (mormot serialize as iso8601) and using any datetime function is broken. This is JS world!
Using helper functions everythig is OK. Template is modified SMS and still there is a lot of SMS code in template. Need more testing on different structures.
@ab we need correct type naming for temporary nested fields (CatNested/CatsNested).
Last edited by ttomas (2024-03-17 14:54:09)
Offline
Pages: 1