I saw this talk with the CTO of the company I am presently with and one thing he said to me immediately afterwards was how it made him think of WCF web services. I think his analogy is strong. Remember how in the WCF XML pattern you could make a model at the web service itself, a POCO, a then the applications consuming the SOAP API could have it without having to make duplicate code on their end to duplicate the shape of the object? We don't really have that with REST do we? We are just used to making our own object for a packet to send. That doesn't seem strange when you are just interacting with an API, but what if you are both authoring an API and consuming it in an Angular app that you are using as the front end for a .NET Core project which has REST endpoints as it's "other" front end? Then you will find yourself writing duplicate objects in both C# and TypeScript. There is now (HTTP) State Transfer which is a service that may transfer state between the server and the client. Swashbuckle for Swagger adds some metadata to what is at a REST endpoint to make the object to be communicated from C# to TypeScript intelligible at the TypeScript side. You need to use HttpWithStateTransfer in lieu of the usual Http at an Angular app to get this stuff working. Anyways, this should alleviate some of maintainability pain of having two objects on two sides of a divide and having to remember to update each one whenever there is a change. Imagine if multiple Angular apps use a common API. Then things could get dicey indeed without such a solution. Other things said: ng eject as a command means that I don't want to use the Angular CLI anymore and that I want to go back to using Webpack. Netty, a Java-based server, is probably the fastest server but .NET Core is still really fast and should be thought of as a fast server. Obviously, what Microsoft really wanted was something faster than Node so Node has been the thing to beat, not Netty. The .NET Core SDK has React.js and Angular templates that may be spun up from the command line. The following is a new piece of middleware for pointing an Angular app to a dist folder.
app.UseSpa("/dist", configure: ()=>
{
if(env.IsDevelopment())
{
app.UseAngularCliServer(sourcePath: "ClientApp");
}
});
No comments:
Post a Comment