The simplest way to create an API is with .NET | Minimal APIs

  Рет қаралды 92,160

Nick Chapsas

Nick Chapsas

Күн бұрын

Пікірлер: 181
@dougelk3
@dougelk3 2 жыл бұрын
Thanks!
@AlFasGD
@AlFasGD 3 жыл бұрын
You've successfully made me wanna touch building APIs. I have always been avoiding them and sticking to my area, which is building libraries and now code analyzers, but the simplicity of properly building a functional API appeals to me like it's never done before.
@dsvechnikov
@dsvechnikov 3 жыл бұрын
That's simple until you get to authentication, authorization, validation and other stuff that must be implemented in 99% of real production applications
@johnnyt.2523
@johnnyt.2523 3 жыл бұрын
I started watching your other series where you created the api in the old way, and I didn't really understand how it worked(coming from Django, java). It was the most professional and well structured series I've ever seen! Hope you make a more beginner friendly series explaining the C# and architecture used.
@okbrown
@okbrown 3 жыл бұрын
Beautiful!!! This makes me so happy!! (Says the NodeJS Developer in me!!)
@cethrivias
@cethrivias 3 жыл бұрын
Amazing! I think that this is a great entry point for somebody who just wants to try to write some basic api in dotnet
@bennymountain1
@bennymountain1 3 жыл бұрын
Cool! Now I need to know even less stuff to do my job!
@Lyokou
@Lyokou 3 жыл бұрын
My mind is literally blown away. My biggest frustration with C# is how verbose it is compared to PHP, JavaScript, and Python, and the compiler on change, so annoying. This really makes me want to use now, so excited to play with it.
@cembobiohazard7779
@cembobiohazard7779 2 жыл бұрын
short and sweet. Thanks man 👍
@peymannaji
@peymannaji 3 жыл бұрын
Thanks for the video, I think one of the good use cases for this feature would be creating a mock server or a test API, otherwise I still would choose the old approach for production.
@davidpereira5303
@davidpereira5303 2 жыл бұрын
Really well explained, thanks👌!
@mohamedsalah324
@mohamedsalah324 3 жыл бұрын
Your videos helps a lot thanks for the great stuff
@rockymarquiss8327
@rockymarquiss8327 3 жыл бұрын
Nice.. Thank you for your demonstration!
@alexvanheerden5702
@alexvanheerden5702 3 жыл бұрын
1. This was amazing 2. Seeing you use Visual Studio was quite jarring 😜
@StephenBeale
@StephenBeale 8 ай бұрын
A helpful video, as always, but when I follow along, why does mine need using statements and yours does not? I am using a .NET 6 console app project type - I can't see any icons in any project type that match yours. What type of project are you using? And even when I do add the suggested using statement for Microsoft.Graph.Models, the same builder function is not available. Any help/clarity would be much appreciated. Thanks, Steve
@darianferrer
@darianferrer 3 жыл бұрын
At first I thought it would change dramatically how we structure a project, but on second thought, I think it won't change too much actually (at least for microservices): following your example, I would have a static class CustomersApi, with static methods GetAll, GetById, etc that will be passed to app.MapGet, etc. That way testability for the new "controller" is easy to do, and the rest of the code can be organised in the same way you are used to.
@nickchapsas
@nickchapsas 3 жыл бұрын
That's exactly it. And the cool thing is that this type of routing is more performant than Controller routing so you also get a free performance boost for virtually minimal (no pun intented) change
@lolyasuo1235
@lolyasuo1235 3 жыл бұрын
@@nickchapsas If im not wrong you could use Configure > IApplicationBuilder app to have routing in Startup.cs. I don't know what is happening in the behind, but you always could do this. Ofc the new approach is much cleaner...
@darianferrer
@darianferrer 3 жыл бұрын
@@lolyasuo1235 you are right, it's almost the same thing, but with this new style you get DI by default for example, in the old style you only get the http context (though you can get the service with that) and the configuration here is smaller (lots of defaults of course). The point is, it's great for teaching, PoC, even microservices in real live if defaults are enough
@davidfowl
@davidfowl 3 жыл бұрын
@@darianferrer It's the same tech under the covers and it's as capable as whatever you were using in the past. This new API is a cleaner way to remove boilerplate for common scenarios.
@darianferrer
@darianferrer 3 жыл бұрын
@@davidfowl I agree, seems to be built in what's already in .NET Core, but I was thinking for big monolithic apps which can have lots of controllers, I would still prefer the routing attributes, but that's a personal choice and probably very influenced by me not using this new style yet :D I will still try it because 99% of the time I work with microservices and this seems very good for that
@katsmike853
@katsmike853 3 жыл бұрын
Hey Nick, I was wandering, how would you go about enabling authentication/authorization on this type of an API web app ?
@nickchapsas
@nickchapsas 3 жыл бұрын
It's the exact same as in normal MVC. It's just that instead of having to configure it in Startup.cs you can configure it with builder.Services.AddAuthentication() and app.UseAuthentication()
@codeme8016
@codeme8016 Жыл бұрын
@@nickchapsas Hey there, how would you apply [Authorize] to a single controller endpoint?
@sky_walker_
@sky_walker_ 3 жыл бұрын
Which usings and dlls i need? I dont find the webapplication class.
@StephenBeale
@StephenBeale 8 ай бұрын
ditto
@Mirko_G.
@Mirko_G. 2 жыл бұрын
Thank you Mom Microsoft ! We truly love you ! I will try some spikes with Soc
@basitameen6156
@basitameen6156 3 жыл бұрын
can you do a series on architectural and design patterns for microservices stack
@saadbinsami4801
@saadbinsami4801 3 жыл бұрын
Hi Nick, Can you please do a comparative analysis on Memory and T [ ] ?
@rosspovey1869
@rosspovey1869 3 жыл бұрын
LOVE this! Thank you!
@lardosian
@lardosian 3 жыл бұрын
Cool, gonna wait till November, knowing my luck I would mess things up with preview versions etc!!
@TransparentWorld1275
@TransparentWorld1275 3 жыл бұрын
Is there any advantage to building APIs the older way, besides having more (possibly) organization?
@morgadoapi4431
@morgadoapi4431 3 жыл бұрын
Nick or anyone else correct me if I'm wrong or agree with me. I would see how this is useful for a prototype or very simple application. Introducing this new way of writing APIs in an ENTERPRISE setting comes with a couple of drawbacks. 1. Your developers have to learn new skills to do what they already knew how to do with the conventional way 2. You should build your prototypes as closely to production ready as pragmatically possible, the code should be as close to the existing architecture as possible 3. You lose testability, then again this is not intended for business logic applications only CRUD and manual testing on small endpoints is ok 4. You have limited extensibility because of a simplistic architecture 5. Security has to be simplistic you lose flexibility in this aspect If you keep these things in mind you will have a great time with Minimal APIs.
@nickchapsas
@nickchapsas 3 жыл бұрын
Check my “in defence of minima apis” video
@vert3cx373
@vert3cx373 2 жыл бұрын
Thanks Nick!
@JesseUnderscoreMartin
@JesseUnderscoreMartin 2 жыл бұрын
Hi Nick, at 14:00 it sounds as if you mentioned that this can do 800,000 requests per second. Do you have more information about this, or a source? I may be misunderstanding something. I've been looking at Node vs Go REST benchmarks and they're all in the 4,000-10,000 request per second range.
@nickchapsas
@nickchapsas 2 жыл бұрын
They are plain text responses, Maria Nagaga’s (Microsoft) demo had that slide
@JesseUnderscoreMartin
@JesseUnderscoreMartin 2 жыл бұрын
@@nickchapsas Got it, thanks Nick! And thanks for the vid!
@JesseUnderscoreMartin
@JesseUnderscoreMartin 2 жыл бұрын
20:00 in this video (kzbin.info/www/bejne/Z5XEgHd8pZurrNU) if anyone else is interested, that's a pretty big increase!
@MaxPlayle
@MaxPlayle 3 жыл бұрын
10:20 @Nick Chapsas How would I interact with the Query String using this method? Thanks in advance :)
@romafedor2590
@romafedor2590 3 жыл бұрын
Nick please do something with monitors/timeout monitors ! Thank you!
@EduardoAG
@EduardoAG 3 жыл бұрын
9:20 I guess you can use Global Usings and move the usings on a single separate file
@ronaldoperes1202
@ronaldoperes1202 3 жыл бұрын
How to create a minimal API folder structure? I don't see the "public static void main()" What template do you use in Visual Studio?
@nickchapsas
@nickchapsas 3 жыл бұрын
No template. Just a blank console app. public static void isn't neede anymore. It's just infered in the Program.cs
@ronaldoperes1202
@ronaldoperes1202 3 жыл бұрын
@@nickchapsas ok, and is that only for Dotnet core 6?
@jakebradminster709
@jakebradminster709 Жыл бұрын
Excellent, now I can simplify all my 'Hello World' APIs.
@techman6713
@techman6713 2 жыл бұрын
Hi Nick! Thanks for the video, I have a simple question: is it possible to separate routing to another file, like in Angular?
@nickchapsas
@nickchapsas 2 жыл бұрын
Sure thing
@lollo4711
@lollo4711 3 жыл бұрын
In another presentation for this “new style” - the question if the compiled assembly size will also shrink was answered with NO (which sounded like a pre-compiler that transforms “new style” into “old style” code) @2:11 you say: bitcode gets smaller - but the total size of the compiled assembly remains the same?
@nickchapsas
@nickchapsas 3 жыл бұрын
So that's partially true. The code will get lowered and top level statements and all the cool features will be lowered to the old style which means more code in the packaged version but Minimal APIs the feature, won't get lowered to old MVC style
@lollo4711
@lollo4711 3 жыл бұрын
@@nickchapsas Tnx 4 your answer. Another example came along with no (visible) “void Main()”. How can “void Main()” be made async/sync? Thinking about costs in the cloud (every flop counts;) it would have been really awesome just to start a Web-API with three lines of code - but the code-creator hides a lot of stuff done in the background. So, I would recommend a dotnet-cmd compiler-option to output the fully generated (old style) code.
@nickchapsas
@nickchapsas 3 жыл бұрын
@@lollo4711 You can totally use async in that method. for example if you wanna use the app.RunAsync() method to run the app, you can just to "await app.RunAsync()" and the code will automatically detect it and accept it. Not that it will make any difference in that specific usecase, but it's totally acceptable if you wanna use it.
@AdisonCavani
@AdisonCavani 3 жыл бұрын
What's your thoughts about "new" VS Studio 2022 Preview? I think it's a big improvement over the previous one. Everything runs much faster, especially intelliSense and startup
@nickchapsas
@nickchapsas 3 жыл бұрын
At least on my PC it still runs quite a bit slower than Rider. It's just less snappy. It might be something that I can probably configure, plus it's still in preview, but for now, I can't see myself switching.
@djmotion86
@djmotion86 2 жыл бұрын
2022 freezes quite a bit after waking up from sleep
@pabloturnesg
@pabloturnesg 3 жыл бұрын
Nick do you or your team ocasionally use linked lists?
@LindenMikus
@LindenMikus 3 жыл бұрын
can you do push notifications with this?
@20windfisch11
@20windfisch11 3 жыл бұрын
Will Blazor also use the newer simple API?
@m.wilusz964
@m.wilusz964 2 жыл бұрын
How it's possible that '_customers[id];' in GetById don't throw but return null?
@codeme8016
@codeme8016 Жыл бұрын
I feel in order to skip every single simple Controller I have to add a lot of extra codes/files in order to achieve the same thing. e.g. validating data. What's the point of using Minimal API now? Am I missing something?
@lukmankazeem2188
@lukmankazeem2188 2 жыл бұрын
Dayummmm man, you make it make sense, make sense?
@Layarion
@Layarion 3 жыл бұрын
i'll have to come back to this later, kinda just glazing over me right now. is there a more birds-eye view with wireframe examples of what this is about?
@ofc2463
@ofc2463 2 жыл бұрын
What could be the use of this Minimal APIs? For demo/learning or can it be used in production?
@nickchapsas
@nickchapsas 2 жыл бұрын
Can be used in production
@mmaranta785
@mmaranta785 3 жыл бұрын
That is one huge computer you are sitting in front of
@swathivallabhani6320
@swathivallabhani6320 2 жыл бұрын
Hi Nick, How can i get data from sql in this concepts?? Do you have any example ???
@nickchapsas
@nickchapsas 2 жыл бұрын
In other videos about Minimal APIs yeah
@paulcappello5931
@paulcappello5931 3 жыл бұрын
I like this. Reminds me of Perl Dancer
@pavanchandu6172
@pavanchandu6172 3 жыл бұрын
what about Swashbuckle and swagger injection in the simple API? Is it feasible
@nickchapsas
@nickchapsas 3 жыл бұрын
I should have shown it. It's the same thing as the full api. You need to add the swagger gen and the middleware with app.UseSwagger() and app.UseSwaggerUI()
@ripple123
@ripple123 3 жыл бұрын
you can check out a dotnet standup with david fowler and others about minimal apis where they go into more detail about this new approach
@parlor3115
@parlor3115 3 жыл бұрын
I kinda knew this would happen since they started to refer to dotnet application as "app". Also, isn't that a C# script. Like there are no using statements and all.
@nickchapsas
@nickchapsas 3 жыл бұрын
This is just C#, not C# script. They changed it so a lot of using statements can be automatically infered without the need to be explicitly stated
@godfather7695
@godfather7695 Жыл бұрын
If your api have just one function it is very good, but if you need make som checks or you have n layer architecture...🤔
@megaman2016
@megaman2016 2 жыл бұрын
Where is the port defined?,
@snokzor
@snokzor 3 жыл бұрын
Pretty cool stuff. How is this so much faster tho?
@nickchapsas
@nickchapsas 3 жыл бұрын
It’s doing less
@naveenmishra1778
@naveenmishra1778 2 жыл бұрын
my question is, can a Minimal APIs concept be used in large complex applications
@Vastlee
@Vastlee 3 жыл бұрын
The evil twin Tom Chapsas!
@Morzelius
@Morzelius Жыл бұрын
How those APIs can be used in a real-world project? I mean, it looks fancy on a tutorial. But I don't see how the program can be structured on a large project.
@Maric18
@Maric18 3 жыл бұрын
tbh the simplest way i have seen to build apis is python-flask but this is cool as well :D
@ortundgaming967
@ortundgaming967 3 жыл бұрын
What project type am I using for this? dotnet new webapi dotnet new web dotnet new console dotnet new classlib You didn't show D:
@davidfowl
@davidfowl 3 жыл бұрын
dotnet new web
@JohnZakaria
@JohnZakaria 3 жыл бұрын
Nothing beats fastapi in its simplicity
@nickchapsas
@nickchapsas 3 жыл бұрын
Looking at their hello world example, it looks longer
@JohnZakaria
@JohnZakaria 3 жыл бұрын
Well you get free swagger UI. Type checking in python too.
@shreyasjejurkar1233
@shreyasjejurkar1233 3 жыл бұрын
@@JohnZakaria nothing comes as free. Swagger ui is there in here as well, but it's option for developer to have it or not.
@obinnaokafor6252
@obinnaokafor6252 3 жыл бұрын
@@JohnZakaria C# is strongly typed. Lol
@goodoleme747
@goodoleme747 2 жыл бұрын
Simple in Go as well.
@hasan-ceo
@hasan-ceo 3 жыл бұрын
Awesome! Do I need to map all my 100+ end point in single file?
@davidfowl
@davidfowl 3 жыл бұрын
You can if you want to sure, you can also use methods.
@nickchapsas
@nickchapsas 3 жыл бұрын
Several people asked this. On Tuesday I will be publishing a video that shows how you can structure a minimal api in a more elegant way. These videos are supposed to show you how things work and how to get started. You should never think that this is all there is to it and that’s true for things outside of minimal APIs too
@joe-sydney-au
@joe-sydney-au 2 жыл бұрын
Can you please show a more complicated example, where the API returns a custom Http Status Code and Message (say, for example 422) and capture it with any client-side library (e.g. the Browser's built-in fetch)? Now that's an idea for a video (if you haven't done one already).
@toebeann
@toebeann 2 жыл бұрын
For that, from the handler you would return, e.g. Results.Text("Something went wrong! Oh noes!", statusCode: 422)
@toebeann
@toebeann 2 жыл бұрын
Most of the Results methods have an overload which accepts an int representing a status code. e.g. Results.Json, Results.Content, Results.Text to name a few. There's also the Results.StatusCode method which accepts just an int argument and will not output any body in the response, just the status code.
@TonoNamnum
@TonoNamnum 3 жыл бұрын
Does anyone know how to access the httpContext in order to add a custom header as a response for example?
@AvgDan
@AvgDan 2 жыл бұрын
What's the cleanest way to add an API server to a Windows Forms app?
@filipecotrimmelo7714
@filipecotrimmelo7714 3 жыл бұрын
Ow nice, but I want to see it a real small application. This example with customers is just a hello world. But I love the content and see what is new.
@avtargill
@avtargill 3 жыл бұрын
Agreed. I'd pay for a course that covered a full app (authentication, database, etc.), preferably with tests.
@godfather7695
@godfather7695 Жыл бұрын
I think single responsibility principle is not working here. Class Program must response only one job is to run midleware and application🤔
@Gameplayer55055
@Gameplayer55055 3 жыл бұрын
While you're building a simple APIs, i suffer from problems with tls 1.3 support.
@mahesh_rcb
@mahesh_rcb 3 жыл бұрын
What else is possible in Minimal API .. Out of curiosity 😅 Most demos have CRUD
@nickchapsas
@nickchapsas 3 жыл бұрын
Well anything really. The reason why most demos use crud is to compare it with how less boilerplate code you have compared to full MVC. The rest is the same.
@antonkomyshan1727
@antonkomyshan1727 3 жыл бұрын
Rider doesn't support C# 10 yet?
@shreyasjejurkar1233
@shreyasjejurkar1233 3 жыл бұрын
.NET 6 & C# 10 isn't GA yet!
@CRBarchager
@CRBarchager 3 жыл бұрын
C# 10 is sceduled to be released in November 2021 so no Rider doesn't not support it.... yet!
@MaZe741
@MaZe741 3 жыл бұрын
800'000 requests a second? thats almost a thousandth of a millisecond, how did you get to this number?
@nickchapsas
@nickchapsas 3 жыл бұрын
It’s the number Microsoft gets in there JSON TechEmpowered benchmarks
@MaZe741
@MaZe741 3 жыл бұрын
@@nickchapsas I doubt you can even make a db call in that time, please link the source, its just so unrealistic and depends on so many factors like network latency. you sure this isnt "per minute", for example?
@MaZe741
@MaZe741 3 жыл бұрын
@@nickchapsas also, your demo at 13:14 shows 11ms and 10ms, I dont understand how you would improve this by a factor of 10'000 without some serious scaling solutions like containers, workers or load balancers. There's something else missing here, it cannot just be fastapi by itself working at almost a million requests a second. just nope. And this isnt even connected to a real database yet.
@CrapE_DM
@CrapE_DM 3 жыл бұрын
My biggest thing is TDD. So I would create those functions separately to be testable. But yeah, they've got something similar in Kotlin, and I think Java Spark comes close, too.
@Mirko_G.
@Mirko_G. 2 жыл бұрын
Me too! Im developing rest apis with tdd and Soc its part of that!
@John_FritzTheCat_Doe
@John_FritzTheCat_Doe 2 жыл бұрын
The quickest and shortest API setup you can get is with Python + FastAPI. I'm pretty sure Microsoft has copied that concept (like everything) for their minimal api's.
@nickchapsas
@nickchapsas 2 жыл бұрын
Is it though? FastAPI Hello world is 5 lines of code. Minimal APIs in .NET is 3.
@DiegoNovati1
@DiegoNovati1 3 жыл бұрын
No different from Quarkus, that you can deploy as native or with Java runtime
@nickchapsas
@nickchapsas 3 жыл бұрын
I don't know about that. This looks pretty verbose to me: quarkus.io/guides/getting-started#the-jax-rs-resources
@DiegoNovati1
@DiegoNovati1 3 жыл бұрын
@@nickchapsas The Java code is more verbose than the Kotlin one, but at the same level as the code you have written.
@clearlyunwell
@clearlyunwell 3 жыл бұрын
👍🏽
@jcorrify
@jcorrify 3 жыл бұрын
It's indeed a nice feature for quick work, but I wonder how it will turn out with a real-life situation with a full rest API capability implementing swagger documentation, media types validation, hateoas, authentication, etc... I suspect it will turn into a large unreadable mono file...
@ySomic
@ySomic 3 жыл бұрын
It's more as an introductionary for new programmers or people that are new to .NET. Making it easy to be immersed into .NET. which will really propell the framework (and C#) forward.
@davidfowl
@davidfowl 3 жыл бұрын
Show me your controller with all of those things and I'll show you the minimal API equivalent.
@obinnaokafor6252
@obinnaokafor6252 3 жыл бұрын
@@davidfowl ❤️❤️❤️❤️
@FilmfanOliver1992
@FilmfanOliver1992 3 жыл бұрын
I like ASP Net Core as much as Spring Boot :-)
@KangoV
@KangoV 3 жыл бұрын
Nice that you expose your internal database structure through a HTTP interface. If I saw a developer working for me do that, I'd haul him/her over the coals. This kind of example is teachinf developers very bad habits. Oh I just tried this and did it in around 67 lines of Java code.
@greyedout
@greyedout 3 жыл бұрын
Where exactly did he expose the database structure in HTTP? I somehow missed that part?
@greyedout
@greyedout 3 жыл бұрын
For anyone also wondering, I was being sarcastic. There is exactly nothing wrong with the code and no "internal database structure" is exposed through a "HTTP" interface. What he probably meant is that he is returning the "database models" without using a DTO. Which is out of scope for this video and also I doubt the 67 line Java code has it implemented.
@denis-suleimanov
@denis-suleimanov 3 жыл бұрын
Well... What if I have a many entities? Controllers - is more or less "strong" structure. And now... microsoft told me "hey! Add all of your endpoints and their handlers to single file".. Thanks, but no. What about multiple attributes (cached, authority, access model..)? Multiline handlers, etc? I think C# is going to wrong path... "divide et impera" isn't?
@nickchapsas
@nickchapsas 3 жыл бұрын
You don't need to have everything in a single file. This can still be "structured" without the need for a controller. Just because those MapGet methods can be in the Program.cs doesn't mean that you can't give them proper structure and move them in a different place. It's more about what you could do not what you should do.
@CRBarchager
@CRBarchager 3 жыл бұрын
Almost any tutorial will not should you the most optimal way of doing things. Just demonstrate a function or a way to do things. Doing it "the right way" will obviously make this video alot longer not having it cramped down into a 15 minute snippet. But Nick gets the meaning out perfectly and it really shows how far .NET have come.
@denis-suleimanov
@denis-suleimanov 3 жыл бұрын
​@@CRBarchager hmm... I don't have any problem with this video or Nick or even Microsoft as a company.. I was saying just about new conception, nothing more.
@obinnaokafor6252
@obinnaokafor6252 3 жыл бұрын
Microsoft never told you that.
@CobeinCobein
@CobeinCobein 3 жыл бұрын
Looks like nancyfx
@chadiusmaximus9350
@chadiusmaximus9350 3 жыл бұрын
you are 100% correct. the Nancy devs went on to create Carter which is the successor to Nancy. David Flower and the ASP.Net Core team took alot inspiration for this team.
@miatribe
@miatribe 3 жыл бұрын
Now add some security to it.
@void_star_void
@void_star_void 3 жыл бұрын
I'm of two worlds about this. More like a love hate relationship
@nickchapsas
@nickchapsas 3 жыл бұрын
The great thing about it is that it's completely optional
@lolyasuo1235
@lolyasuo1235 3 жыл бұрын
@@nickchapsas Seems like they have changed all templates to use the minimal api approach. Even console template is 1 line with just Console.WriteLine()... which personally i don't like it. I don't think there is any real use that will benefit from not having main method. Even a student assignment will propably have 3-4 methods for solving the problem... so you will end up manually adding the old main method. (ofc you can ignore main and just add other methods. but i prefer the old style). Minimal api is a good approach for easy and fast web apis but not for other things. My opinion ofc. I don't like the "scriptish" languages. I would prefer the Visual Studio templates to remain the same and just have variations for the minimal apis.
@chriskeo392
@chriskeo392 2 жыл бұрын
FastAPI beats this by a mile
@nickchapsas
@nickchapsas 2 жыл бұрын
In what? Performance? lolno, even on FastAPI's own benchmarks, ASP.NET is faster
@AnonymousDeveloper1
@AnonymousDeveloper1 3 жыл бұрын
I don't like top-level statements stuff and well minimal API seems to be very strange at the first time. It looks like being taken from Express.js which I like however I'm not sure if it's good to have everything in just one file. It only works in "tutorial hello world" videos and not even slightly bigger application. Could you show us example where you don't write everything in Program.cs? Just split the code and make it clean with interfaces, services, configuration, AutoMapper, entity framework core...
@nickchapsas
@nickchapsas 3 жыл бұрын
No one ever said that minimal APIs mean that you should have everything in one file. Check my “In defence of minimal APIs” video
@AnonymousDeveloper1
@AnonymousDeveloper1 3 жыл бұрын
@@nickchapsas Thanks, I'll watch this video soon. Generally speaking I'd like to see examples which don't show everything in just one file. I wish .NET designers, Microsoft and community guys will show easy and detailed tutorials in the future. So many questions, not so many answers.
@luderx
@luderx 3 жыл бұрын
But anyway, who uses Microsoft Java?
@anotherme4638
@anotherme4638 3 жыл бұрын
Wait a minute, Is this actually .NET 6 C# ? it feels like python or nodeJS thanks man for the demo.
@bennymountain1
@bennymountain1 3 жыл бұрын
They've made it so if you don't declare class and static Main method in a file it generates when you build your app, if that's what you mean. I think this was in since .net 5. Handy for a "hello world", but I haven't used it, honestly.
@stepanhakobyan
@stepanhakobyan 3 жыл бұрын
The second part of the video shows how to get some unmaintainable code. Enjoy.
@nickchapsas
@nickchapsas 3 жыл бұрын
You don’t have to keep everything in a single file. You can structure it like any other project. The only thing that changes is the entry point and you get routing performance over controller for free.
@twiksify
@twiksify 3 жыл бұрын
How would one go about unit testing such an endpoint? As I see it you no longer have a dedicated method, instead you'll have to launch the app in order to expose the endpoint in form of an API call. The lambda can be replaced with a testable method call, however how can I verify that the method is configured for the right API endpoint path as well as that the method isn't falsely being used by another endpoint? Selenium can be used for integration tests, however it'll be rather hard to maintain mocks for unit test of an endpoint which you don't have the entry point context.
@yearlyoatmeal
@yearlyoatmeal 3 жыл бұрын
This guys style and content is absolutely on point but at times the speed with which he speaks combines with his accent in a way that can make it just a little bit exhausting to follow. I wished he would either slow down just a tiny bit, or alternatively try to improve his pronunciation. Not wanting to be rude or ungrateful here!! He's the best C# content source on KZbin imo but that's kind of why I'm taking the time to provide this unsolicited feedback here.. anyways, thanks for all the fantastic free content and insights! Keep it up. 🍺
@nickchapsas
@nickchapsas 3 жыл бұрын
So, this is kind of the double edge sword of this type of content creation. Long videos just dont' get clicked and I have plenty of data to back that up. If I do talk slower, then the video will get longer and it will definately cross that threshold. The majority of the comments I get about the content's pace is positive, mainly because the people who watch my content are intermediate to advance levels. Ofc that means that when I do a more entry level video like this one I will inevitably be too fast for some people, and you're right me accent doesn't help. Ultimately if people think it's too fast, they can use the KZbin speed controls to slow that down. I'd rather have people slow a video down than people speed a video up.
@pilotboba
@pilotboba 3 жыл бұрын
You can speed up or slow down the You Tube play back. I watch most things like this at 1.5x or 1.75x.
@yearlyoatmeal
@yearlyoatmeal 3 жыл бұрын
@@nickchapsas fair enough!! Yeah I can see that too fast for some is probably better than the opposite. For example Tim Corey tutorials are basically unwatchable due to their mind numbing snail pace. That guy can take a half hour to explain something that should take a minute... Thanks again for providing such great value!!
@zedmagdy
@zedmagdy 3 жыл бұрын
: Am I a joke to you bro?
@obinnaokafor6252
@obinnaokafor6252 3 жыл бұрын
--OR-- Console.WriteLine("Hello, World);
@zedmagdy
@zedmagdy 3 жыл бұрын
@@obinnaokafor6252 You just forgot to add .csproj file so it's not gonna work
@obinnaokafor6252
@obinnaokafor6252 3 жыл бұрын
@@zedmagdy csproj adds itself
@nanvlad
@nanvlad 3 жыл бұрын
Waiting for 'import' and 'export' directives to include .cs files into a main module :)
@fulmetalmage
@fulmetalmage 3 жыл бұрын
Cute. I can see it being useful for faas or micro services. However i think it will turn into a shitshow in a monolythic api.
@nickchapsas
@nickchapsas 3 жыл бұрын
What I am interested to see is how people will decide to "structure" this approach. It is meant to be really easy to get started but in order to become managable and not violate the principles we like using, it will probably need some grooming.
@Insel03
@Insel03 3 жыл бұрын
@@nickchapsas I imagine I would create a project per resource/domain where I can pass my app builder into. This new approach really would make it a blast to build API modules. Is there proper middleware support?
@davidfowl
@davidfowl 3 жыл бұрын
@@Insel03 It supports all of ASP.NET Core, all of the features.
@abdelhaleemalfreihat7261
@abdelhaleemalfreihat7261 3 жыл бұрын
so what is the point? we all know we use .net for enterprise projects not for building hello world applications!, I think .net development team just trying to make it work in all ways and having as many features as possible, I don't like it :)
@nickchapsas
@nickchapsas 3 жыл бұрын
Well that's not true. Enterprise projects doesn't mean big code bases. I am working on "enterprise projects" but I can totally see myself using Minimap APIs for them. Simplifying the entry point and giving a 40% performance increase over the MVC approach is something I just can't resist. It's the thing that the entry point calls that hide the complexity, not the entry point itself. That's why it works.
@lolyasuo1235
@lolyasuo1235 3 жыл бұрын
@@nickchapsas Where 40% performance comes from? is it from the minimal apis approach or from the NET 6 in general? Yea i see a chance for minimal apis in production. You can put em behind some APIM for protection and youre fine.
@nickchapsas
@nickchapsas 3 жыл бұрын
@@lolyasuo1235 It comes from the routing. Controller routing is more complicated and less performant compared to Minimal API routing
@davidfowl
@davidfowl 3 жыл бұрын
@@nickchapsas Right, it comes from doing less :)
@manuillo94
@manuillo94 3 жыл бұрын
100% of th15:18
@ivancarmenates84
@ivancarmenates84 3 жыл бұрын
All that is good but wring code sequentially like old fashion programming languages like basic doesn't really makes the point, that is just a mess show.
@nickchapsas
@nickchapsas 3 жыл бұрын
Check the followup video
@scryptum
@scryptum 3 жыл бұрын
This an Express server style. Copy paste !
@tootytooty5135
@tootytooty5135 3 жыл бұрын
Lol... 0 improvement other than making it into less code which makes it less readable too.
@AnonymousDeveloper1
@AnonymousDeveloper1 3 жыл бұрын
Yes, very bad decision. I was writing about it but they can't understand.
The best way to create a string in C# that you shouldn't use
16:41
Nick Chapsas
Рет қаралды 70 М.
What's New in .NET 9 with Examples
25:02
Nick Chapsas
Рет қаралды 71 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
To Brawl AND BEYOND!
00:51
Brawl Stars
Рет қаралды 17 МЛН
You are doing .NET logging wrong. Let's fix it
25:29
Nick Chapsas
Рет қаралды 175 М.
Stop Using FluentAssertions Now
9:25
Nick Chapsas
Рет қаралды 58 М.
Don't throw exceptions in C#. Do this instead
18:13
Nick Chapsas
Рет қаралды 265 М.
The Fix For Your Database Performance Issues in .NET
9:12
Nick Chapsas
Рет қаралды 89 М.
Stop using the HttpClient the wrong way in .NET
10:14
Nick Chapsas
Рет қаралды 198 М.
Elegant API Versioning in ASP.NET Core (Web API)
21:27
Nick Chapsas
Рет қаралды 96 М.
Making async code run faster in C#
10:28
Nick Chapsas
Рет қаралды 108 М.
8 await async mistakes that you SHOULD avoid in .NET
21:13
Nick Chapsas
Рет қаралды 317 М.
Why Developers and Companies Hate .NET 9
10:56
Nick Chapsas
Рет қаралды 58 М.
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН