Introduction to NestJs | Backend Framework for Angular Developers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey let's discuss about Nest chairs which is a back-end framework and today we'll see why it's built for angular developer so let's jump into the video hi everyone this is subrath and you are watching fan of realistic so on this channel we'll make videos like this which is related to programming and web development so please consider subscribing and hit the Bell icon if you haven't yet today we'll discuss about Nest chess which is the famous back-end framework built on node.js and according to my experience nest.js you can see is inspired from angular and spring boot spring boot which is a Java framework and angular you guys know so what they did mostly is they took some concept of springboard or popular Frameworks and a lot of concept from angular like if I trying to say we have pipes we have Interceptor we have guards we have Services we have modules we have dependency injections and a lot of things which is quite similar to angular so if you know angular quite well or if you know angular decent enough then you should look at nest.js even if you are not working on back end and if you already know back-end means if you're already working on back end and you are working with some other framework please have a look on nest.js because it builds upon node.js and is quite awesome how it handled things and all and to start with messages we need our Nest CLI and to install Nest CLI we can write a similar command to angular CLI which is npm install hyphen G at Nest slash CLI I have already installed nest in my system so I will just go ahead and start a project and to start a project we can use the CLI command in angular we use NG and here it's Nest so it's Nest new Android name and it will ask us like which package we want like npm yarn or pump so I will go with npm then it will to create a simple project for us and we'll go inside and and we'll see what all it's created so before I look into the code I just like to say that Nest you just Express by default if you want to use firstify you can go and change it and it start using first device so that that's the beauty of having a architecture framework that you don't need to worry much about how the abstraction things works if I'll open the application in the vs code if you see here we have source and test source is where we have our application code and test is for testing if I go inside the source and now you can relate a lot what I was talking about with C similar to angular so if you see here we have appservice.ts main.ts app module.ts and I know you can relate app controller.ts and spec file and I will explain what's a controller here so if you go to the main TS and the main.ts is responsible for the bootstrap of your application similar to angular in our bootstrap method what we are doing is we are using Nest Factory which is a factory method which is creating app instance from our app model and we'll go and go and see inside what's inside the app model is and we are seeing our app should be listened to Port 3000 so in a short note our booster method is saying that our app will be now hosted in Port 3000 so now if you go inside our app module here also you can relate similar to NG module we have a at direct module which has Imports controllers and providers the Imports and providers you know if you know angular but if you don't know angular so Imports are like external modules which you need to import inside your app module and provide us are the external services and what is the service I will explain which need to be used inside our app module now we come to the controllers so controllers you just think like your entry point to your project when you have some API endpoint so controller is response sensible to exposing those API endpoints so your controller should only be responsible for getting the call from UI calling the services or calling other methods and Responding back with a desired response so if you go inside our controller here you can see that you have a class as app controller and you have a decorator here which is at the red controller and it says that now our this class will be registered as a controller and if you not give any path inside this that means it will be to the base means your slash but if you want to give some path like suppose user now your this control will be accessed via slash user so in our case localhost 3000 slash user and if you know HTTP method then you know that we have some HTTP verbs those are get put post delete patch so similar to that we have some decorators in Nest so we have at the Red Gate at the red post as a red put another deletes and so more so if you want a method to be a get call then you can write at the Redcat so suppose if you want this to a post call then you we can write at the rate post and Nest will make this as a post call obviously you need a request body and all but that's a separate scenario and if you want to give some specific path like we have discussed for the whole controller but if if you want to give a specific path for a specific method then you can do like this but it has lot more than what I explaining now and we will cover all in a separate video just dedicated to controllers like water methods we what we can have how you can use middleware how you can use interceptors and all so we'll cover it in depth in upcoming videos so please stay tuned for that now it will see that what is a service if you go inside our app service you can see we have at the rate injectable that means now this class this app service can be injected to a instance of your module that means state of this service will be accessible to this module and as is injectable that means it is injected as a Singleton instance so now if you see here we have get hero get hello which is returning hello world fun of heuristic which we are calling from our get hello method which is a get call for our service now go to our package.js sun and here if we see we want to start our application to start our application that there is two ways you can just run npm run start which is just do and let's start but I want to start the application with watch mode so I will do npm Run start tab so just go here and I will start the application with watch mode if you go to the application here if you see I have just hit low color 3000 by default browser makes a get call as you haven't provided any path here so it's hitting this method and from this method we are calling our app service get hello and this is returning hello world and now if you want to go for slash test and we can test that here slash test and if you see we are returning hello directly from there so that we that we got in the response back so this is just a tip of Iceberg what Nest can do so Nest this is a complete back-end framework and we're going to see all in our future videos and means in this series so we'll see how we're gonna connect with databases how we want to use orm to handle your databases and how we're gonna you divide Your Nest service to multiple micro service how to integrate with it with Dockers and and multiple things I also haven't covered like guards pipes intercept and all that which we're going to cover as a separate videos because those are in-depth comms that we need to cover so this video I just made just to give a overview and just to start towards backend development so please hit the like button if you like the video till now please do subscribe to the channel and don't forget to hit the Bell icon so that you will not miss future videos please do share this video among your friends family colleagues so that they also know that how awesome Nest is we're going to meet in the next video till then stay happy bye bye
Info
Channel: Fun Of Heuristic
Views: 933
Rating: undefined out of 5
Keywords: Angular, programming
Id: dNOutxyYgIE
Channel Id: undefined
Length: 9min 11sec (551 seconds)
Published: Wed Sep 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.