Skip to playerSkip to main content
  • 5 minutes ago
🌍 Planning to travel, study, or find a place to stay?
At Mava, we support you every step of the way ✨
🎓 University applications
🏡 Housing & rental services
✈️ Travel bookings & tour packages
Free consultation | Full support | Options that fit you
📲 Contact us on WhatsApp: +905073410436
Or connect on mava with BasemHalaika
Mava company
in the bio

🌍 Seyahat, eğitim veya konaklama mı planlıyorsunuz?
Mava olarak her adımda yanınızdayız ✨
🎓 Üniversite başvuruları
🏡 Konaklama ve kiralama hizmetleri
✈️ Uçuş ve tur programları
Ücretsiz danışmanlık | Tam destek | Size uygun seçenekler
📲 WhatsApp: +905073410436
Ya da mava'da BasemHalaika
Mava şirketi
biode

🌍 هل تخطط للسفر أو الدراسة أو تبحث عن سكن مناسب؟
في Mava نحن معك في كل خطوة ✨
🎓 التقديم على الجامعات
🏡 خدمات السكن والإيجار
✈️ حجوزات الطيران والبرامج السياحية
استشارة مجانية | دعم كامل | خيارات تناسبك
📲 تواصل معنا عبر واتساب: +905073410436
او تواصل على mava مع BasemHalaika
Mava شركة
in the bio

Category

🤖
Tech
Transcript
00:00hello everyone and welcome back in the previous video we installed Node.js and
00:06all the tools will need to draw out this course today we are finally going to
00:13create our very first Node.js project by the end of this video you will
00:18understand how to analyze a Node.js project what the packaged JSON file is
00:25how to install Xpress and how to create your very first web server let's get
00:31started create a project folder the first thing we need is a folder for our
00:39project I am going to create a new folder and create backend courses
00:53I will create backend courses
01:13I will create it
01:22you can give it any name you like now let's open the folder in the virtual
01:28studio code
01:32and we will go to file and open folder and open the backend courses
01:43now utilize the project right now this folder is just an empty directory
01:48Node.js doesn't know that this is a project yet to utilize a new Node.js project we use
01:56the following comment npm in it we will click on the terminal and a new
02:04terminal
02:08npm in it
02:13but when you run this comment npm will ask you several questions for example package name
02:20version description interpoint author license you can answer this question on
02:25npm by one but if you just want to accept all the defaults value you can
02:30assembly type npm in it
02:32tag one
02:33tag one
02:35tag one
02:35tag one
02:43then therefore automatically answers yes to every question and create the project
02:48instantly let's run it perfect now you will notice that a new file has appeared inside our project called package
02:57.json
02:58like this package.json
03:02understanding package.json so we will open package.json now this package.json so what exactly is this file
03:13think of package.json as the identity card of your project
03:18it contains information about your application and keeps a track of every package your project depends on
03:26let's open it you will see something similar to this like this name backend courses version
03:35don't claim the name it has a full Does itis Gilbert
03:42doesn't claim I think it will notice the words that Knitlin type
03:47let's understand its property. The name is a similar project name. A version tells us what
03:56of the application of the application we are currently working on the main
04:03property specifics and the inter-point of the application in our course and only as
04:10we start executing from a text to us the scripts section contains comments that we can run using
04:18NPR and we will work with scripts much more later in this course for now just remember
04:26that package tourism is one of the most important part in every continuous project
04:34in store Xpress now our project exists but it doesn't actually do anything yet we need a framework
04:43that helps us build web servers easy that a framework is called Xpress Xpress is one of the most popular
04:51technology as a framework in the world instead of writing hundreds of lines of code using the built-in
04:59DDP model Xpress lists us the built API within and with much cleaner code let's install it let the
05:09firewall command and install Xpress install Xpress
05:27we will run it
05:35now you have noticed two new things first a folder called node models second a file called
05:43package log to JSON node models package log to JSON
05:50what's node models many beginners get confused when they see this folder node models
05:59don't worry the node models folder contains every package that your project needs not only Xpress itself
06:07but also all the libraries that Xpress depend on this one that's why this folder becomes very large
06:14one important thing to remember is you should never manually edit anything inside node models
06:29node.js manage this folder to JSON and node.js manage this folder to JSON
06:34package log to JSON
06:37this file records the exact versions of file if installed package this ensures that everyone working
06:44on the project installs exactly the same version this helps avoid compatibility
06:51problems between different types of files
06:58create index.js
07:03now it's time to write our first code we create a new file called index.js
07:12index.js
07:26index.js
07:27so node.js will start executing from here import Xpress the first thing we need is Xpress itself
07:35we import it like this we import it like this const Xpress
07:40const
07:48Xpress
07:49index.js
07:50index.js
07:52index.js
07:53index.js
07:53index.js
07:57index.js
08:02index.js
08:04index.js
08:05index.js
08:05index.js
08:06index.js
08:06index.js
08:06index.js
08:08index.js
08:09index.js
08:10index.js
08:10index.js
08:10index.js
08:10index.js
08:14and this line loads the xpress package into our application create the xpress
08:20application next we create an xpress application const
08:27const
08:32think of this object as your interweb application everything will build a row of this course will be attached to
08:41this object
08:42routes middleware authentication everything create your first route, now let's create our very first route
09:02let's understand what's happening here
09:05ipl.get creates a route that responds to get requests
09:09the first argument is a url since we write a slash this means a home page
09:16the second argument is a callback function whenever someone visits this route xpress executes this function
09:25inside the function we send a response back to the browser in this example we are simply sending hello world
09:38a lesson on a port our servers are most ready the last thing we need is just telling xpress to
09:47listen for incoming requests we do that like this like this the number 3000 is the port number you
09:58can think of a port as a specific tool into your application your computer has thousands of ports our
10:06application is listening on port 3000 whenever someone sends a request to the to this port xpress will handle
10:15it run the server now let's start our application inside the terminal type node and the x node
10:25and the x node and the x node and the x node and the x node and the x node
10:33and the x node if everything
10:39if everything works correctly you should see server is running on port 3000 like this
10:47now open your browser go to http localhost 3000 like this
11:03like this http localhost 3000 and you will see hello world
11:12this is the very first backend application you have built it might look simply now but every large
11:18application starts exactly like this
11:32conclusion excellent work today you have learned how to utilize an mgs project
11:37using npm explored the purpose of the package chosen file installed xpress understood what node models
11:45and package log chosen are created your first xpress server added your first router and started the server
11:54on port 3000 in the next video you will dive deeper into xpress and learn how to routing works
12:02including handling get postpart and elite requests as well as sending different type of response
12:10thank you for watching and i will see you in the next video
Comments

Recommended