Node.JS Tutorial for Beginners | Learn NodeJS Step By Step | NodeJS Training

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello well welcome to the course of complete guide to create REST API with nor GS and Express I am really excited to have you on board let's see what we are going to cover in this video by understanding the first and important element of our jewelry and that is no js' so what is no GS so as per the definition nor GS is a JavaScript runtime built on Chrome's v8 engine and in short nor GS is the largest ecosystem it is a production proven environment and node.js is used in a thousands of companies in a large application again it's an open source it runs on a various platform we can run it on Windows Linux Mac etc right so you might be wondering what nodejs can all what no jets can do so no js' can generate dynamic page content it can create read write delete files on the server largest also collect data from they form data and node.js can add delete modify data in your database so one can use node.js for create entire web application but in this course we will be only talking about the rest api s-- alright and to perform the rest api s-- we are again using an express framework now this X node JS Express framework is again a popular middleware so Express is a minimal and a flexible node.js web application framework that provides a robust set of feature to develop web and applications it fascinates the rapid development of node-based web application and some of the features are it allow us to set up middleware to respond to HTTP requests define a routing table which is used to perform a different action based on HTTP method and URL make sense so we will be using this express as a middleware for our node.js application so what is raised API so REST API is an acronym for representational state transfer an almost meaningless description of the most used web service technology rest is a way for two computer system to communicate over HTTP in a similar way to web browser and servers sharing data between two or more system has always been a fundamental requirements for a software development and we will be creating the REST API throughout the course then what we are going to learn during the entire course so during the entire course we will be creating the REST API is using that ms SQL database and also at the end of the course I have added two more videos how we can make a connectivity to MySQL and MongoDB make sense then we are going to learn some important features of best practices how we can store the production and development configuration in file and how we can use that then we will also cover the exception handling in that exception handling we will be storing some of the what we can say errors in our JSON file and then we will throw the respected error message whenever it is required we are also going for authentication we are also going to cover JWT that is Jason Jason web token and then we can also see how we can manage authentication in our nor GS application then we will also see how we can debug our application we will put a debugger then we can see how we can use a logger in our node.js application then we can see how we can deploy it to our cloud server and many more so let's get started so yes for downloading or installing the nodes yes to your local machine we are just navigating to this node JS dot orgy the official documentation for node.js and there you can download the stable version so while recording this video the stable version is twelve point eighteen point one so it might be differing this video alright so I have already download the stable release for me and my local machine so I will dot to do it again so you just click over here and download the required setup and just follow the instruction in the setup and that is it you are ready to go with your node GS so now what I do I'll open up my command prompt and on my command prompt you first need to check whether the node.js is installed correctly or not so here I can just write a command node - V and then we can check the which version of nodejs we are running on my local system and for the nor package manager again we have to write npm - v and that will display which version of node package manager we are using in our local machine alright and one more thing we can check with whether the node is installed correctly or not we can simply run the node and then we can write of the expression so let us say 2+2 and that will run make sense so yes we have installed node.js correctly on our local machine now let us try to create our first hello world application we will be creating a node.js application from the scratch and for that first we have to create a node.js application so over here I'll be open up my command prompt and I navigated to the directory where I want to create my node.js application and here I will say npm and in it and then it will prompt us for some of the name like package name version so i will just hit enter and go with the default values so what it will do it will just create a package dot JSON file for us so i will just close this terminal and if i just open that raced api project with my ID as an ide I'll be using v vs code you can use whatever the ide you like so this is the package dot JSON file which got generated when we write that npm in it make sense so before starting with anything with node.js we first need to create a server for HTTP right - to handle our request or to run our request right so what i will do on my package dot jason we can write the dependencies tag over here or what I can do is I can open up my Google Chrome and I can search for that NPM packages so this is the package for HTTP so I can copy this and I'll on my terminal what I will do is over here I'll open up that integrated terminal know that which vs core comes with an integrated terminal and I can write that come on NPM install and add now that we'll install that dependency in my package dot JSON file over here you can see it has added the dependency and this is HTTP make sense and if you know the dependency you can directly write over here like say for example HTTP and here you can also name the version number and then what you can do is over here you can also use that NPM install so that will do the same thing what that command will do for us so whatever you want you can write it over there right the next step we need to create our first file so here I could say index dot J's while we run through that wizard writing that NPM in it there is a question like what should be your entry point and I I have already gone with the default value and the default name is index dot GS so on my index dot JSON use that HTTP package we just installed so over here I could say require and inside that I'll be using that HTTP package and then I could say Const and I could say server and here I could use that HTTP instance and I could say create server now that creates server you need to pass a callback function so inside that create server as in parameter I'll be writing a function with a two parameter request and response right so if you are new to the REST API so I'll just briefly introduce introduce you this request is an object which we are passing from our front-end or you can say from our postman or a rest client and this response is an object which we are giving back to the user and if you want to read more about that request and response I'll share the document attached with this lecture so over here what I can do is I could say response dot and and over here I could say hello world make sense and then finally we will say start our server on some pot right so here I could say server dot listen and here you have to specify a port number on which you want to listen your node.js application so over here I could say listen it on pot number 3000 and if we save everything and now if we open up the terminal again and let us rerun the applications over here I could say index dot GS so node and then file name which file you want to run so if everything went correct and now let me just open up the browser and here let me just check localhost colon 3000 all right then if everything went correct you can see that hello world is ready this is how we can create our first hello world application with the node GS now with the next video what I'll do is I'll create an application in which we can create a simple crowd operation with ms SQL database so now we have to install Microsoft sequel server 2017 Express edition you can use any of the Express Edition I am just using 2017 so I'm just navigating to this Microsoft official website and then you can just press this download and then you can go with the instruction for the setup and then just press next next next and then you are good to go with Microsoft sequel server 2070 correct then after having installed that a sequel server Express Edition you will also require to download sequel server management studio that is SSMS now you can just press this download sequel server management studio and again you just go with the Installer and then you are good to go and you can use that SSMS so I have installed both sequel server management studio as well as that Express Edition so now on my SS MS sequel server management studio I have created one user and here I've selected the authentication to SQL Server authentication and here I have to pass my username and password so that I can connect to my sequel server database and on this database directory you can see I have already created a demo database and if you have knew how to create a database using that sequel server you can just right click on this database and just create new database make sense and then inside this demo database navigate to the stables and here you can just right click on the table and you can just create a new table makes sense so exists easiest thing and I have created this product table and that product table is having a five columns ID name price description and quantity simple nothing fancy right and it is having I think one or two record already inserted so we can you know fetch the records and what I will do is we have one testing data over here so what I will do is I have created a stool procedures for that for fetching the products I have this get all products and for adding a product I have this air product delete product update product and find product by ID so this is my store procedure for getting all products and it is just returning us all the columns so here I am using select star from product in this course we will make direct queries as well we will use stored procedures so I will just briefly give you introduction about this store procedures store stores procedures are nothing but a subroutine function which already stored our query just we will pass the parameter right so over here we are just adding a new product to the table the name of store procedure is add product same way we'll have delete and update products so here you can see the delete product also and the same way update product so over here you can see we have this much store procedures make sense and I will also show you how we can write a direct query from nor J's application right but more mostly throughout the course we will be using store procedures whenever it is possible all right so now on my application in our node.js application we have we will require one you can say mediator or one me one you can say mid one one are one layer which can talk to your database ms SQL so to do so what I will do is I will just open here and search for NPM and ms SQL package now this package is is responsible to talk with your database ms SQL right so if you want to make a connection with MySQL you can also use that connector and in in this course even we will see how we can connect to different different databases MySQL MongoDB and so on right so over here on my application I'll open up the terminal window and as I told you we like to we need to write that ms SQL plugin alright so I'll be installing that is SQL and next plug-in we will require that Express framework so what I will do I will also copy this Express and on our node.js application we will need to install that Express also so what we are using is like Express mssql and an odious application make sense and this is got installed and if you open up your package dot JSON file you can see on dependencies you will have two more dependency about Express and mssql so now we can use that package in our applications all right as a next step what I'll do is I'll create a class which can make a connection to my database and for that what I will use is I'll use this documentation of ms SQL plug-in and here they have mentioned how we can create a class and we can pass the parameters and it has a connect method and inside that connect method we need to passed our configuration all right so if you want to read more about that mssql plugin you can use its documentation and right now on our application what I'll do is I can create a connection class so on my solution Explorer what I'll do is I'll create one file and I'll name it like Bibi connection dot j/s all right and now inside that Bibi connection dot GS I'll create a method which will connect through my mssql plug-in to my database so over here I could say Const and I could say that ms SQL and I will say require and I will point through that ms SQL right and now I'll create a class I name it to DB connection and we need to export this so over here I could say module dot exports and new D connection so this is a skeleton or you can say blueprint how we can create a class and then inside that baby connection class I'll create my method and I'll use that asynch and await because if the statement will take a time to execute you can know that all the calls in this JavaScript application are a synchronous right so I am saying that we need to wait for this statement to be executed so we are using that a sink and a vet keyword and over here I could say get connection and inside that method I will be using try catch to handle the error and over here I just say whatever the error just I'll use a console dot log and error right now we are not throwing the error back to the user or something we are just printing it on a console but later with the course we will also see how we can deal with in errors and inside that try I could say return away and I could say SQL ms SQL object dot connect now this connect is a method of that ms SQL plug-in right and inside that method we need to pass the database object and for that what I can do is I can simply create a database object over here with the username password server name and database name so these are my local configuration like username is as a password is sa server is local host database name is devil so whatever whatsoever is your configuration for your local database for this ms SQL database you can pass it over there so in my case the database name is demo alright and rest are the all the configuration to connect my ms SQL server so this is how our first file will look and I'll name it to DB connection dot GS now as a next step what I will do is I will just open up my solution Explorer I'll create one more directory I'll name it two modules and inside that models we need to create let us save one more directory and I'll name it to throw duck so what I will do I will organize everything related within a product table inside that product module so inside that product directory I'll create a product dot controller dot GS so we're here I could say product dot controller dot GS then again I'll create one more file again inside that I could say product dot GS and last file is product dot mssql dot GS all right so this mssql dot J's file will require our DB connection file because here on this DB connection we are making a connection to our database right so what I will do on my mssql product dot mssql dot GS file first we need to import that product DB connection over here so over here what I will do is I'll say Const I'll say Ms SQL connection and then what I will do is I will give a path to that DB connection file right so what I will do I will say double dash and here you can say DB connection dot J's so it's just double dash is moving up to up to the directory right so now what I will do is I could say clasp and this is my product ms SQL class and inside that class what I can do is here I can again create a method and I name to get all products and finally we need to export this over here I could say modeled on exports and new product mssql class alright now inside this GATT all products method what I will do is I will first call my get connection method so over here I could say mssql connection object dot GATT connection now this will make a connection to my database right and here this statement will take a time to execute so over here I'll be using that Evette keyword right this is what we already used over here same way after I complete completion of this execution what I want to do is I want to make a query to the database so over here I could say constant result and then I could say same object connection object dot here we can use the request so that everything is mentioned in ms SQL plug-in and then we can write our query method so over here we can specify our query so over here I will say select star from throat and then I will show you how we can call the store procedures as a next but first I want to show you how you can directly query to your table and then what I will do is I will say return and response now but obvious this statement will take some time in executing your query so if we didn't specify a weight over here it won't wait for this statement to be finished and it will return us the result and but obvious that's a null or undefined right so instead of that we can also use the evade keyword so we are saying like wait for this a statement to execute first and then move to this request making sense so right we created one method and now on my product class what we have to do is we will import that mssql class over here so over here I could say product mssql and then I will say require and [Music] I'll give a path to it so over here product mssql and I will create a class product and finally we need to module dot exports and new product making sense guys now inside that I'll be using again asynch and await get all products is my method but now this method will have two arguments request and response and as I told you request is an object we are supplying from our front end and response is an object we are giving back to the user all right so now inside that GATT all product what I will do is I will be using try and catch just try and catch what if there is an error we will deal with an error handling so over here I could say console dot log and log my error and inside that try what I will do is I'll use that object of this product mssql class and I will call my get all product method so over here I'll create a variable Const output and I could say Evette and product mssql dot get all products alright and we will made till this matter will be executed and finally what I'll do is this response is an object which goes back to the user so over here I could say result response dot send and I want to send my result back making sense now we need to create a control so on my controller what I will do is I will just import that for a class so I could say Const and here I could say product and then I will say require and here let me specify a product class then again I could create a class and I name it let us say product controller and inside that controller I'll be having one constructor that constructor required one parameter so I will name it app and inside that constructor I'll be using over here more module dot exports and we need to finally export my controller right now here inside that constructor I will require router object alright so what I'll do is I'll be here importing Const and was there I could use that Express object so over here I could say Express and here I can make it require and I could say Express now this is the framework we have installed earlier and then what I can do is over here I can create another object router and that router I could say Express dot Raptor alright so here I'll be using that router method and now what I can do is I can use that router object and on my class inside the constructor what I'll do is I'll say router dot if the method is type of post or get or put or delete so here we will check the request type so here I could say if the base pass a base path is there so over here on my constructor I can use that app dot use and here we can specify our base path so over here I could say use this as my base pad so I'll say draw dots and what I'll check on this get requests if there is nothing out after the base part right so I'll say if the part is empty then go and call my from my product class call that get all products method make sense all right so so far we have created DB connection this will responsible to make in connection to my database now we are exporting this DB connection so on my ms SQL file I am importing that Bibi connection I am calling its method GATT connection and Here I am writing my statement or a query to be executed then on my product Here I am be checking the my request and response and based on that I will be calling my whatever the method I want to call so get all florets and then on controller I'll define which method is to be called based on the request I received make sense now we need to create one index dot J's file or you can say a module file which will define which controller to be called and when all right so now over here inside my module directory I will create one more file and I'll name it to index dot GS and this file will define which module or which controller we need to call and when alright so based on our request it will call the controller so here I could say module and inside that module I'll be creating a constructor so constructor will require an object so here I'll initialize it with my local object so I'll say this dot F equals to app and then I'll create one method init method and inside that init method I will initialize by construct controller so over here I could say product controller and I'll give a part to that for a controller so inside that required I'll say right from product directory get my product controller and then I could say product controller and this dot all right so I am just passing this reference what we have received to this making sense and finally what I will do is module dot exports and I will export this module make sense all right do not forget to use this exports so here on all my class I am just using that and yes here on the product controller as you can see we have used this class syntax but we have not make it new so instead we can write a new or we can remove this so I will just remove that so that's it we already created a module files now it's time to create app dot gs5 so on our root level on our application level right after that package dot Jason what I will do is I'll create one more file and I name it to app dot G s and inside that app dot G s what I will do is I will just initialize my application level setting so here I could say I'll be using that Express over here so over here I could say Const app and I want to use that Express so first we need to import the Express so over here I could say Const and Express and now I could say require and I'll use my Express package make sense then I could say let us say Const AB and I want to use that express method and then what I'll do is I'll create one method and I'll name it to init method so here I'm not creating a class so we are using a JavaScript syntax and we are using we are creating a function and the name of function is in it and inside that init matter what I'll do is I'll be using my module so over here I could say Const and app routing because that request will flow to this in it and this init will flow this request to our model file so over here I could say require and then what I will do is I could say modules and next I'll say Const app modules and now I'll say new app routing mix-ins and here we are passing our object app and now this app is an object of this express or you can say it is a reference to that express framework make sense and then what I will do is app module now this app module is an object of this err outing model and we have in it matter over there also so here on my product module you can say dot in it alright finally we are calling this init function so here I could say in it so that will execute that function while this app dot GS is called and then I could say module dot exports and I will export my object make sense now this index dot J's is the first file which got executed when you run your application right sorry this is not the next dot J's we have to call the index route index dot J's right so this is our route file which got executed when we saw our application right so we need to call app jiae's over here so what I will do is I will just get rid of this and instead of that I will just create index dot J's so that we can make a request to that app dot J's so over here I could say Const and app that will require app dot J's so over here I could say app and then what I'll do is constant server and I could say require then I will make an HTTP as in package dot we need to create our server so I'll say use that app as your object make sense and so from line number three it will call our app and in app dot J's it will execute our init method and from that init method over here it will goes to that modules and from that modules over here it will comes to this and from here it will goes to that product controller so now over here on product controller it will call our get all product method and from here it will execute my mssql file and it will call to the database this is how the application flow is going on making sense now on index dot J's as a next step what I'll say is server dot listen and then I will listen on whatsoever part number you want so here I will specify the port number then you can specify the host name so here I could say localhost and that's it as an third argument you can create the list function so I could say that function and I want to listen the server and over here I could say console dot and I could print a message server started all right so now if everything went correct and if we start our server by writing node and index dot JSP an error after outing is not a constructor all right so we have one type over there so if we navigate to this app dot GS over here so so it is showing the error is on line number nine on app dot GS so let me just find the error so it is showing the error over here it is not a constructor so that's on my module here we have made a typo we need to write the class name so class name is module right so now if we rerun the application again and if we can save and rerun it again and now it is showing that server is started and now on my browser if I say localhost 4001 slash API slash v1 this is my base path and this is my controller products and if everything went correct you can see we have the result all right so this is how by default result it is returning to us instead we can J it you can see like it is returning the result two times right so it is returning as two different object record sets and record set right so whatever the result we want to send back to the user we can use any one of them so on our application while we are just returning the response on our as mssql file we can right over there response dot recordset so here I could say record step mixing so that will now again I'll say real in the application and if you run this again you can see we will have only record alright now in next video we will complete the operation with an product table we will write the path for add update and delete so I just try to explain that how that request flows in our node.js application to the pictorial representation so whatever the request you made from your client first it goes to index dot JSP chiz our default entry point for our nor J's application then from that index dot J's two it will went to F dot J's and from that F dot J's two it will went to the modules index dot GS and there we registered our all of the controllers and our controller holds the path so based on that that from that product controller our request will flow to the product dot J's class there we have our method which in turns invokes that product mssql class and then using that BB connection we will make a connection to the database and then vice versa so in in in database will respond send back to the DB connection through that product mssql then again it flows to the controller and then back to the client making sense this is how our requests will flow in that node.js application so in this video what I will do is we will see how we can call the store procedure instead of writing the direct query over there so what I will do is instead of this query we we'll just call our execute method so and then inside that execute method we can write the name of our store procedure so over here I could say get on products make sense and now if I save everything and let me just reload this word so I could say node and index dot JSP file up the again the records yes the data is displaying but now this time it is displaying through the store procedures right so now is it next what we will do we will write the methods for add update and delete and we will see how we can perform that crud operation through the stroll procedures right so what I will do as a next I will just copy and paste the methods over here so I already created this add product and inside that add product as you can see it is having some parameters input parameters and that input parameters are the variable name or you can say scalar variable which we have already created on a store procedure alright so this name should be the same product name price description alright and then finally execute I will be calling my store procedure making sense same way we are creating a method for update delete and fine floral by ID all right now on my product class what I need to do is we need to make you can say a functions for calling that methods so over here I can just duplicate this and what I will do is instead of this get all products I could say add product requests and response are there in now what I'll do is instead of this gentle product I can call my advocate method now inside this ad product method we need to pass an object which we have sent through our front-end all right or you can say with our request so over here I can use that request dot body because we will pass the object through our body only right so over here I could say add product and here we are using request dot body at the same way we will be using this again and we will call that let us say delayed product an on delete product what I will do is we are not sending the ID in in a body we instead we will send the ID through the parameter on your URL so on delayed what I'll do is I'll create one more variable and say it ID and what I'll do is request dot params and from the parens I could get the ID all right then what I will do inside that try I'll write the eve and I'll say if there isn't an ID just I want to print an error message here I can say console dot log and ID is not passed all right and when we see how to deal with an error handling we will also see how we can cover the exception for this but as of now we are just logging the error and if there is an ID instead of this request or body I will pass that IDs my parameter so here what I will do I will call the product mssql dot delete product and on delay product I will pass the ID making sense then as a next argument I'll create one more method and I name it to update and I name change it to update and update is the same like an ad so what we will do is we will just pass the body over there so instead of that delete we will call that update product method and inside that update product method we will pass our body make sense now then as next we will need to create that find product by ID so over here I could say a sink or we can simply copy that and here we can say find product by I all right again we will need an ID and who were here instead of calling this method I will call the fine product by ID make sense so we have created five different method one is forget all products one is for add product delete product update and find by I now on my controller we have to define its path so on my product controller over here we need to define path for every you know every end path for every method we need to call so over here first we will define the path for that ID so I will copy this paste over here and over here I could say that should be a parameter path and I name it to ID and if it is there I want to call that let us say products dot find product by ID make sense then again I will check if the router dot request type is post and if there is nothing apart from base path then I could say call my product dot add product method make sense then again I could say router dot request is type of put here I'll check the request and again I'll say if there is nothing in the path apart from the base path I'll say call my update product and finally we will call our delete method so over here I could say called the delete and on delete we can check for a parameter and I'll name it to ID all right so here I could say product dot delete product making sense guys so this is how we define the routes and then finally routes are defined we already registered it we have to do our adjustment on our app dot J's because we are sending a data through our body we need to import or we need to install a package and the package named body parcel right so on our first we have to download that body parts of package and on our package dot Jason so I loop one of that package dot JSON file over here and on my package dot JSON file I'll install that body parts of package right and as I told you if you know the dependency you can write it I inside the dependency or just go and search for NPM body parts of package and then you'll have the command after in writing that dependency over there we need to write NPM install so that our dependency got downloaded right after that we can use it on F dot GS so on our app dot GS we first need to make an import for body parcel so over here on my app dot GS what I will do is well I'll say Const I could say body parcel that should be required and then I could say use that body parts or package making sense then what we can do is like we can use that body parcel to limit our body so by default limit of that body parts or packages up to 4 MB you know if you pass an object greater than 4 MB then nodes yes we not able to handle that so later on in this course we will also talk about uploading the files so what I will do over here I'll say the Jason limit to 50 MB and the same way else a URL encode limit to 50 MB so if we upload a file still 50 MB it won't give us in any error making sense now if I close everything and let us try to rerun this server so over here I could say no index dot JSON this postman is required to make a call to the api's right so what i can do is i can create a separate method for it so first method i created is a cat and imma get i'm making a call to my server and the URL is four thousand one and let us try whether it got succeed or not right so yes it is able to fetch the records so now what I will do is I'll save the request first and I can save it to my collection so the collection is named two products at back-end so here you can search for that collection here you can search products app back in alright so I am storing it inside that and I will give it a name so here I could say get all shoulders so that can you know you can share this entire document to your team so I will say to the products make sense and now what I will do for adding a new product I will copy this entire object make sense then what I will do I will create a new API a new request and I'll change the matter to post and I'll paste the object on a body and on body I'll say role and here I'll paste it in our insert add product we don't need to pass the product ID because it's an auto-generated column so here we'll just pass for argument name prize description and here I could say testing - and the price I'll change to 100 point 50 this is my description and quantity I'll say 120 making sense whenever we are making a post request it is mandatory to pass and header so here I'll say content type and I say application Jason making sense and I will copy the endpoint URL over here paste it over here make sense and now we will try to send the post request and wait for the response yes now the record has been added to the database let us check our database first so this is our product table and if we open up this table we can see that should be two records right so now it is only one record so let me just check for the error first it is just we have to refresh it this is how it is displaying the records so testing two prices hundred and fifty fifty and quantity is 120 alright so I'll back to this postman I will again save this to my collection I'll name it to like add product so that when we say share this document with anyone it is able to understand and we will store it to the product app back in make now we will try to make a delayed call so over here instead of my API 4001 I could nine thousand one two four thousand one and here I'll pass my ID to two and again I should make a call to the server right again it will try to delete a record with the idea of two and here if we check on our database there isn't any record with the idea of two so that is why it shows an output zero rows affected that means that should on any record bility now which record we want to delete with the idea of three all right so we will pass the parameter you can say the ID and now the ID is three and now again if we make a request you can see the affected Rose is one and now if we refresh the table over here so you can see that record is removed from the database make sense now we will try for the update method so first let me just save this request and now what we will do we can try this for the same update method so what I will do is on that add product I will just copy the entire object over here and I'll create an another request and on that another request I will change the type to put and on my body I'll paste that copied object over here alright but now with update we need to pass the product ID which record we want to update so over here I could say product ID and now we have only one record within Product ID of one so over here I could say testing one then my price would be 150 point 50 then we'll have the squanto tea to 100 all right and now we need to pass the URL over here so I will copy the endpoint paste it over here on update we didn't require to pass the parameter through the URL because we are passing it through the body on the headers we need to pass content type application Jason alright and now we will try to make put call to our API and let us check again it is saying rows affected to one now let us open our database instead of this testing data it should display test data one so if we check again that is testing one price is also updated and quantities also updated so our services are working as expected alright again I will share this end point on my collection so that we can easily share it with our black NP moreover front-end team so I'll save it I'll name it let us say I named it to update product alright and same collection make sense that is how we will perform a basic crud operation with our nor J's application alright to summarize everything what we have done so far we have created that DB connection dot JS file in real well it is not like this we are not storing our well configuration to the file hard-coded instead in a real application we will have some of the different model like we have development environment we have a production environment staging testing so we want to run the configuration according to which environment we are running so we will see in the next video how we can use this same architecture with the based practices so this is the file which talks within database then we created a product dot ms SQL file so there we are executing our store procedures or you can simply file your queries over here right so then we have created a product controller and product class and that product class will pass the parameters through the request body or through the param make sense and here we can validate whether the week send the check for the ID whether we can validate it or everything we can do it over here all right so we will see how we can do the validations later on in the course then we will have that product controller here we are defining all the paths for our product controller making sense and then we are registering our model so inside that modules we have the index dot GS and based on this we are passing request to our controller and app dot GS is the file it's the first file which transfer your request to the models making sense so have your requests flowing from one file to another first file to be run is your index dot GS from that index dot J's you are using app dot J's from the app dot J's to your module index not J's then from that module to your controller controller to class and class to mssql making sense ok in the next lecture we will see how can we use the best practices
Info
Channel: Questpond
Views: 2,049
Rating: undefined out of 5
Keywords: node js tutorial, nodejs, node tutorial, node.js tutorial, nodejs tutorial, learn node.js, learn nodejs, node js, node.js, nodejs beginners, node, what is node.js, what is nodejs, node js tutorial for beginners, server side, mean stack, js, server, web development, javascript, beginner, backend, node js crash course
Id: AarsRnh6CPw
Channel Id: undefined
Length: 62min 47sec (3767 seconds)
Published: Mon Jun 29 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.