www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Dangular - D Rest server + Angular frontend

reply "Jarl =?UTF-8?B?QW5kcsOpIEjDvGJlbnRoYWwi?= <jarl.andre gmail.com> writes:
Hi

I have created a personal project that aims to learn myself more 
about D/vibe.d and to create a simple and easy to grasp example 
on Mongo -> Vibe -> Angular.

I have been thinking about the possibility of embedding D code in 
diet templates, as for ex to set api urls. Right now the urls are 
statically defined in the diet template. Other than that the 
example app is really not the best example with Angular because 
it uses root events to signal between controllers, but it works 
as a bootstrap example. I am thinking to create another view that 
uses ReactJS because its much much more better than Angular.

Project is located here:

https://github.com/jarlah/dangular

Any comments are appreciated. Especially about the D part, 
because the Angular part is really just to make it easier for me 
to test, and it took like half an hour or hour to trash up (not 
using angular on daily basis)...

I want to especially note a problem i have in the D code. Its 
about deserializing json data for creating a new person. I cant 
use the same struct for creating a new person as for returning a 
list of or a single person, because i want to return the ObjectID 
when I am querying mongo. I thhink the conversion from Document 
to PersonDoc is an operation that ensures that i am only 
returning explicitly what I really want to return. Any excess 
data in the collection is discarded. Nice for example to hide 
extra details for normal users, for ex.

So, there is two structs, but I really only want to have one. 
Should I use classes for this? Inheritance?
Jul 19 2015
next sibling parent "David DeWitt" <dkdewitt gmail.com> writes:
On Sunday, 19 July 2015 at 19:54:31 UTC, Jarl André Hübenthal 
wrote:
 Hi

 I have created a personal project that aims to learn myself 
 more about D/vibe.d and to create a simple and easy to grasp 
 example on Mongo -> Vibe -> Angular.

 [...]
Nice. I was thinking about doing one up in React but haven't had much time for D the past few weeks. I quit Angular due to React and all the nonsense regarding 2.0.
Jul 19 2015
prev sibling parent "Etienne Cimon" <etcimon gmail.com> writes:
On Sunday, 19 July 2015 at 19:54:31 UTC, Jarl André Hübenthal 
wrote:
 Hi

 I have created a personal project that aims to learn myself 
 more about D/vibe.d and to create a simple and easy to grasp 
 example on Mongo -> Vibe -> Angular.
Nice ! I'm also working on a project like this, using some paid angularjs admin template from themeforest, although I'm powering it with Vibe.d / Redis and PostgreSQL 9.4 with its new json type.
 controllers, but it works as a bootstrap example. I am thinking 
 to create another view that uses ReactJS because its much much 
 more better than Angular.
ReactJS has been very promising and I hear a lot of hype around it. However I believe Angular lived through its hype and is now more mature in plenty of areas, for example its Ionic framework for cross-mobile apps is reaching its gold age with seemingly fluid performance on every device! With vibe.d being a cross-platform framework, you'd be even able to build a Web Application that communicates with a client-side OS API, effectively closing the gap between web dev and software dev.
 So, there is two structs, but I really only want to have one. 
 Should I use classes for this? Inheritance?
Vibe.d is famous for its compile-time evaluation, understanding structures like with reflection but producing the most optimized machine code possible. You won't be dealing with interfaces in this case, you should look at the UDA api instead: http://vibed.org/api/vibe.data.serialization/. For example, if your field might not always be in the JSON, you can mark it optional. struct PersonDoc { optional BsonObjectID _id; ulong id; string firstName; string lastName; } You can also "compile-time override" the default serialization/deserialization instructions for a struct by defining the function signatures specified here: http://vibed.org/api/vibe.data.json/serializeToJson or the example here: https://github.com/rejectedsoftware/vibe.d/blob/master/examples/serialization/source/app.d This being said, your questions are most likely to be answered if you ask at http://forum.rejectedsoftware.com
Jul 19 2015