YouTube Transcript:
02.Introduction to N-tired architecture with NodeJS
Skip watching entire videos - get the full transcript, search for keywords, and copy with one click.
Share:
Video Transcript
Available languages:
View:
on okay so we'll be using njs as our
programming language uh so nodejs is
basically a JavaScript runtime that you
can install within your machine and um
you can develop lot of applications
including backend front end or even
mobile application if you like so all
you need to do is um based on your uh
operating system uh you need to install
not Chas within your machine in order to
get started on this so I'll be uh using
um the latest not not the latest one at
least the um not JS version available
right now so let me share my screen and
show you guys what I
screen okay so uh basically what you
need to do is you you need to make sure
that um you guys have njs installed
within your machine and if you if you do
not have nodejs just it's like a basic
simple installation if you're on Windows
you just have to download the binary
execute same goes to Linux and Mac as
well so I'm in my Mac Show the
instructions um for downloading and
downloading and installing is pretty
much simple I all I have to do do is
install it and
uh for my personal preference I would
like uh to use not the binary version
but uh something called
nbm uh not version manager as it calls
so NVM is an tool that help us to
build uh a tool that gives us ability to
change our not environment so you guys
know they um not has different versions
or different environments that I can run
with so I have
uh the latest version maybe some my
projects would be in older not version
so in order to do the version changes
everything NVM is a great tool so first
install NVM and using NVM we can install
uh the
desired um
desired um desired no um n as as as we
speak uh so right now if I I run not
minus V that indicates the version that
I am in currently I am running version
19.9 it might be changed based on what
you have installed at least install
something latest something about
from node uh 18 so that's uh that is
like the latest one do not install very
old version that would uh definitely
leave you guys um with some um headaches
okay so right now I'm having not
1944 and not come coming with um a lot
of uh tools that we can uh use okay so
basically when we are developing an web
application or when we are developing
some sort of uh um some sort
of um mobile or web application we do
not start from the scratch nowadays okay
so the different Frameworks um different
uh uh uh different programming languages
most of the time they have what we call a
a
CLI uh a CLI would be helpful if you if
you like to generate um application
rather than doing it yourself rather
than doing it you're doing it from
scratch sometimes those Frameworks help
us with not not only setting it up but
when we when we want to deploy the
application okay so for instance we want
to run this in uh some sort of a
containerized environment or if if you
need to run it somewhere somewhere in
the cloud the Frameworks and the CLS
gives us those abilities as well so we
do not want to reinvent the wheel okay
so the application itself will generate
uh very self sustained uh self maintain applic
applic
that application would uh will be able
to run and uh you you guys can uh
leverage the uh leverage the existing
applications or leverage the existing
testing Frameworks and lot of things
pre-built for you okay so the CLI tool
that I'm going to be using is what we
call index okay so index is um index
what we call called uh monor repo tool
okay if you do not know about monor
repos uh just give you a simple hint
like uh rather than putting all your
codes in different different
repositories we have one single
repository that use for all our code
management so uh make sure uh you have
NX installed in your machine so if you
have not installed okay if you have it
not installed then you can have the
command npm npm also is a command that
comes with not okay so once you have not
installed you have not npm as well npm
stand for not package manager which will
help us to install dependencies packages
third party dependencies and all those
things so I have npm installed in here
as well so not package manager uh this
is the version that I'm currently
in so using npm I can install NX
okay so by default as I mentioned
earlier you have not and npm using npm
you can in you guys can install LX so
simple command will be
npm install minus
GNX okay so uh let me double check the
[Music]
NX yeah so you can use the in uh NX
command uh if you if you if you like or
you can have uh what we call the uh npx
command npx stand for like uh rather
than having NX globally installed minus
G in here indicating that okay for the
whole computer we'll be using NX but
right now uh if you do not want to have
NX within your whole machine uh so what
we will do is we will install using npx
it's like a temporary thing that we will
be developing so uh I will be using npx
in this example so I'll be working with
um I'll be uh I'll be in my temper
directory so I'm I'm not going to be
able to um have this project afterwards
and I hope not to continue um uh this
after the lectures as as soon as I'm
done with it I'm going to be get ring of
this project so what I'm going to do is
uh I I will say NX again and NX will
give us okay uh this is the command if
you want to create a workspace okay so
workspace is something rather than other
than generating a simple um simple
application a workspace uh contains uh
uh tools uh generated application and so
on and so forth so do not worry about
those things right now all you need to
know is is like workspaces single uh
single place that you can work with Okay
so all you have to do is run this
command npx create NX workspace at
latest which means we will be using the
latest workspace in here we have not
selected any um anything um anything for
the application right now we'll be
working in uh Solly on the simplest uh
workspace generation so I'll I I will um
I will uh uh I will just name me my
um um name my uh
uh name my workspace as f s ft okay so
uh you can name it whatever you want and
probably you'll go with something more
meaningful so um it will ask whether you
to proceed I'll say yes and depending on
your internet connection depending on
what what what sort of uh what sort of
uh connection that you guys have you
will get uh immediate response on all so
uh next thing is um it will ask what
sort of uh application that you need to
generate so NX is a multi uh multiple
platform supporter that means you can
create a react application new
application angular or not application
since we are working with a web
application so these are like front end
web applications so we'll be focusing on
in a different uh lecture on those
things right now we will be focusing on
N architecture so it's easy to
demonstrate n architecture with the
backend project so I'll choose a not and
there are lot of options that you can uh
select from
here so these are the Frameworks or
the um all the templates that you guys
can use so I'm going to be using
something that um I find
quite easy to work with which is called
njs okay you guys can select either one
of these make sure you know the
um make sure you guys follow the same
architectural pattern that we're going
to be using so I'm going to select
njs and whether it's asking for
Standalone or integrated right now I can
go with integrated mono or standalone
the difference is if I if I selected
integrated monor repo then I can have my
front end uh application in the same
repository that's what I meant by monor
repos if I say Standalone that's going
to generate on the njs application I
don't I won't be having any other
application other than an sjs
application that means only a back end
application since I'm not going to be
integrating anything to this one I'll
just stand
alone and this is a Docker file I would
rather not go in
there uh CI building no thanks I do not need
need
that so right now we what NX is doing is
it is um based on the inputs that I have
given uh it is creating a simple web
application uh for us
and by by the time uh the application is
generated uh we'll be able to uh work
with the that so uh it is downloading
all the dependencies it needs that means
the web application it's not going
to not going to be developing itself
that means it needs third party
dependencies there are dependencies in
hand right now it is generating all the
dependencies and take caring of
generating my project so what I'll do is
I will um I will see into the newly
created workspace so I will go to CD wsf
and I'll start code from here
here
uh let me share a new share you guys won't
see I have show code and terminal and
Sh okay um
so uh make sure you guys open it with
your stud code or something that that's
that's uh up to your liking right now
developing web application using
um uh using uh vs code is like really
easy so uh I would uh I would suggest
use something like vs code or
intellig uh platforms if you like
so um it's going to it's still
generating an application for me and um
I'll um brief briefly talk about uh the
application architecture otherwise you
guys U find a lot of files in here and
which will overwhelm you guys so I'll
just give you a brief introduction on
what each of these file represent if you
want more detail uh let's uh look in in
a separate session on those things okay
right now the most important things that
you guys know is this package as so
package simply represent all the
dependencies that we have within our
project let me Zoom it in a little bit
so you guys can
see so this uh this give us a little bit
idea of uh the uh little bit idea about
the our application so these are the
scripts these are the things like we
will be um using to start the
application build the application and
test the application okay so these
script will help us to um do those
things these are like metad datas about
the lensings and everything and we have
these these things called uh
dependencies so these dependencies
represents um what sort of things that
we'll be using within our application
since we using sjs so there are like
dependencies which needs to run the
application um so these dependencies are
needed and there are few de dependencies
these de dependencies what we call is um
these are the things that we need in
order to develop the application but at
the end we won't be using these U Dev
dependencies at the production build we
we would not use um
um [Music]
[Music] uh
uh
um um uh something like uh we'll be
using uh using these things in um in
development but not
uh um development using um in the de
sorry we'll be using these things at the
development time but not at the um not
at the uh frun time okay uh give me a
what Happ
Happ
so um in here uh we we have the Linux uh
terminal so if you do not have a
terminal um there are few options for
Windows uses uh you can use the command
line CMD tool which is available you can
just uh search for CMD tools it pop up
something similar not the exact thing
but something similar zmd tool will um
will help you guys to uh come across uh
the command line uh tool and the easiest
way to verify that you have installed
nodejs is to execute this command not
minus V okay so if will give you guys
whether you have installed nodejs or
not okay so so this indicates we have
installed nodejs successfully using this
nodejs we can
uh start uh developing applications okay
we we this is the runtime for our
application we have the runtime ready
now we can develop applications okay so
noj comes with a package manager okay a
package manager we can simply put it
help us to uh develop application faster
build application faster and execute
some comms so not has a package manager
we called it not package manager simply
put npm okay npn stand for not package
manager so not package manager will help
us to get uh libraries uh from internet
that we can use so we don't need to
develop our own libraries from scratch
we can use existing not uh libraries
within our application okay for example
uh let's say we want to write a a simple
web application okay we need to write a
simple web application in order to write
a simple web application there are like
servers available in handling request
response and everything so we can do it
from scratch of course we can write a
nj's class for that but there are
already built packages that can do the
do the thing so for
example uh if you go noj's uh website sry
sry
npm npm
repository okay so this is where you
guys can get um [Music]
[Music]
um um this is where you guys can check
upon what are the existing package
managers out there okay so packages uh
what are out there so for example I can
search package something called a web
server so the well known web server is called
called
Express okay uh do I have Express yes so
expr is a package or a library that we
can use that to generate a simple web
application okay simple web application
so I I can use express rather than
developing everything from scratch I can
simply use express to develop a simple
application you guys can see there are
examples in here that you guys can use
to develop a uh simple uh web
application all right so um the next
thing that uh we need to do is we need
to install this exess application right
we need to install this web web culation
in our machine so how do we use that we
use the command npm install or npm I for
short so using this command what it will
do is it will uh install um the express
uh library or Express package then we
can use within our JavaScript code okay
so we do not develop everything from
scratch we use an existing package and
using that package we can develop the
software so likewise there are like
thousands of not packages that you can
um use with
uh when we are building application we
will be using lot of not packages okay
like Express there is TS Libs you don't
need to know everything even I don't
know what are the all the libraries are
doing for but at least what are the
JavaScript development uh helping
libraries out there you guys can use
those okay so right now I'm I'm uh
simply using uh a simple not
uh simple not package simply using not
package manager to install a bunch of
other softwares that will help me to
develop a simple application okay so
make sure nod is there npm is there and
when you're using npm make sure you know
what is the uh what is the library or
the Frameworks or the things that you're
going to be using in here otherwise it
won't help you to work with Okay so uh
we have npm installed so we can I can
even see the not package manager version
okay so right now I'm we're using the version
version
9.0 which came along with the this note
version so not package manager help us
to get uh all the dependencies and
running those script and everything U so
we should know what are the packages
that we going to be using Okay anything
up until this any questions with the no
unclear any questions with regarding
all
good just give me the go ahead then I will
getting yes
sir all right
so uh so we have npm installed uh not
package manager and
now what we need to do is um as I
mentioned earlier um we need to generate
a web application okay especially uh web
application which will uh which will
give us some
U API okay uh we can expose some uh data
so what what we're going to do is we
going to um develop a rest API uh which
is uh which is something like uh when
when we using a browser or a web client
we will request something from the
server and the server will respond a
certain um certain information backwards
it's like when we are looking into a web
web page okay right now when we go to a
npmjs.com we get uh HTML
response right we get the HTML response
so in a rest API we would get uh we
would not get X HTML response but a
simple Json response we will see all
these things in action so right now what
we're going to be building is uh a
simple rest API okay if you do not know
rest API um have a have a quick look
around it that is like the most common
way of communicating these days and rest
days and there is grab ql one of the
major uh major things that we will be
using so make sure if you do not know
what we going to be building just have a
look around what is a rest API but in
this scenario we'll be uh developing a
simple rest API okay and we will be
developing the API and we will be
applying the basic architecture patterns
in while we are doing that we will uh
you guys can see if you guys can see um
take this example this example the
express example it's it is also
developing something like what we call
uh a rest API it's not practically a
rest API but it is something like that
but we can also work uh we can
also uh we can also show a simple
application uh using um these packages
okay let's let me demonstrate uh so you
guys can get a better idea we'll just
use a simple express application and we
will see the pros and cons of this
application and why this application or
why this architecture will not suffice
for uh uh suffice for a huge application
why we need to architect better than
let uh let me quickly grab this example
and try to run this so let me uh once
again um I'll go to a directory uh where
I can work uh work without an issue I am
in my M temporary directory which is
like u a directory will be uh once I'm
restarting the computer whatever in this
temp will be gone okay but if you're
working uh something solid uh project uh
choose my documents or projects or
somewhere else so you guys can work
there so I will create a
directory mkd or you can say right click
new folder mkd I will say
Express okay so I can go to express uh
Express uh directory now if I use vs
code and I will open the project in that
same directory so I am I'm actually in
the directory that I have created in
under TMP Express I have opened it using
V code you can use file and open and you
will you will have the same thing as as
I did earlier
on so
uh let me share that as well
now okay so I have the open editor for
that so uh within the express uh Express
directory I'll I'll simply create a
simple application I normally we called
it at app.js which indicate application
so I hit
enter and I will copy paste the
application that is giving in here and
you guys can see um this is going to be a
a
developing I'll show you guys what is
the outcome of this so the outcome of
this application would be simply showing
a message called hello world that is the
outcome of this
things okay so in order to run this code
in order to run this code what I need is
something called Express so I I did not
I do not have Express install in my
machine I I do not have Express
uh within uh my U within my app.js so
what I'm going to do is I'm going to
install Express the package that I show
you guys in here using this command npmi
Express so make sure uh my terminal is
where I I am in the current uh in the
current project I'm going to say npm install
Express uh let me copy the command in
here and I will install Express so what
it's going to do is using npm I will
install Express into my uh Express into
my coding area so if I go back in here
you guys will see few things have
changed around here okay the first thing
is um there is something called not
modules so not modules containing all
the dependence is within my application
so I have only depended on Express but
the thing is Express is not going to run
its own Express is depending on other
packages okay so this is the express
that we have installed but Express is
not going to work alone Express
depending on other packages like e Tec
is something Express will be depending
on all the other packages directly or
indirectly depend on Express so Express
is depending on all these packages so npm
npm
is smart enough
okay uh if you are using Express you
need uh e Tec also within you so it will
install e Tec so sometimes e teac might
be e teac is uh e te is uh depending on
something else it will download that we
can actually see what's depending on
what so if I go to the
package this is like where we uh where
we uh have all the dependence is list
out in our application so right now you
can see uh my application am depending
on Express especially Express version 4 uh
uh
18.2 so I'm depending on this version
okay so this version you can find within
not modules this is where the express
binaries are the library things are and
you will find Express in my not module
and if you go to express also there will
be a package Json and within Express JS
you can see what are the packages
Express is depending on so it depending
on accept cookies fresh lot of things
are in here I will take something like
accepts so whenever Express is is
installed it automatically also download
accepts this Library I don't know I
actually do not know what it even the
purpose is it is installing accepts so
if I go back to accepts in here and I
can see packages accet is depending on M
types and everything so you guys get the
picture there's a tree of dependencies
all these tree of dependencies will get
resolved until the package do not have
any dependency IES to depend on okay so
the last one would definitely not have
any dependencies by that
time we will uh we will have all the
dependencies installed so now in order
to run my application in order to run this
this
application all the dependencies all the
necessary application stuff is here here
with me I do not need anything else to
run everything is runnable at this
moment so you guys get the idea on the
package Json so package Json F all the
dependencies what are the libraries that
we are develop depending on it's going
to have uh those information in here and
all the dependencies that we going to
have will be within this not module
application now so this this is going to
contain all the binaries and this is
going to express what are the things we
are depending on okay for now just
ignore the package lockon it's going to
specifically lock the version okay so we
created appjs app.js this is the file
that we have created and this is the
package we are depending on so anything
up until this uh you guys did not
get please confirm that you guys got
continue any
anything if if you if you have anything
at the moment just interrupt me and I
will I'll will answer okay so basically
this is what what not JS application
would look like but if you if you if you
use uh if you use something like a Java
application the terminologies will
change but the application uh structure
most of the time remain same so for
example if you're using Java web
application then uh we will have we we
won't find Express in Java right Java
Java is a different ecosystem it has own
libraries and everything you won't find
Express in Java but you will find
something similar you will find
something like Tom cat underthrow or
even um there are reactives web services
there are a lot of similar products
which represent a webite okay
so Java do not have npm not package
manag is available for not npm available
for not JS
only so you won't find that in Java but
you will find something similar like
Maven gr the echo system grows okay so
you all you need to know is uh there are
strikingly similar things that happens
in different Frameworks different world
but they they have the same thing okay
if you're developing a same thing if you
go to C World okay so if you go to cop
World okay you have Frameworks like net
Co and IIA server those kind of things
same thing you will have the new get
package manager like you see npm in cop
you will say new get package manager all
you need to do is adapt to that
framework okay so there are a lot of
Frameworks and everything's going on if
you're using python you will see um you
will see uh uh Frameworks like d Jango
okay fast API as your server and you
have unicorn servers and the package
manager or when you want to handle your
dependencies you will use something like
pip Python uh package manager for
installing different like so you guys
get the idea they have all similar
things we will get uh we will uh
when we are looking at other
architectural patterns I'm not going to
go everything inj we will have other
projects concluding in other Frameworks
like we'll create a mobile application
you'll create uh
uh [Music]
[Music]
uh you will create um micros service
application so we will use different
Frameworks and different things okay
only thing that you guys need to know
that different Frameworks have different
package managers different uh servers
depending on what you are developing you
guys need to adap to that that's it okay so
so
um so what we can do is uh um we have
installed the necessary packages which
we can run this uh application now we
need to run this okay we will run this
and see the see the result and we will
get back and try to understand this
piece of code okay all right in order to
run this application what I need to do
is I need to be in the same directory
where my project
is yeah so if I list down all the things
uh in my directory I can see that appjs
is one one in here that means I can run this
this
application and you guys can see the not
modules and everything so all I need to
do is run this application and see
whether it is starting a web server so
in order to run this application all I
have to do is say not app do sorry
sorry
app.js okay so if everything is in order
if I if I do not uh if I do if I did
everything correctly so what should
happen is it seems to be running
running
um it's not giving me an error so I I
suppose this is running so all I need to
do is um you guys can see uh it is
listening on P 3,000 that means this
application is now running the web
server is running uh the web server is
running on Port 3,000 okay so if I go to
Port 3,000 within my machine I would see
something okay let's see what we can get
when we go to Port 3,000 so how we can
access since this is a rest rest API and
simple simple rest API is there how
definitely I can use uh our browser okay
we can use the browser if I'm not using
the browser I can use a
client okay so I can use a client like
curl um so I can look around it so I can
use something like curl uh
local local Post Port
3000 okay so it's simply saying uh go to
this address Local Host is my own
machine since I'm working on my same
machine I it will be Local Host the port
I'm interested in is 3,000 so if I hit
enter and I get the response back
message hello work okay so I can get the
similar or the same result since this is
a simple web API if I go to my
browser and if I go to Port 3,000 Local
Host 3000 then I get this same message
but in a little bit of Json format you
might see something like this I have
this um Json passer which help me to
understand this one a little bit easier
so you guys can see that I am seeing the
message hello world which I put in the
section but if I want to say
hello R leer
this would not probably show yeah so I
have changed the code hello R so now
what I have to do is go to my terminal
and you guys can see it is still running
the old version I will terminate it you
can use control C uh or in in MOS would
use uh in even contrl C by hitting
control C it will terminate the running
process now I can run again then not
app.js and if I go back to controller uh
if I go back to my browser uh still I'm
seeing the old one if I refresh and I
can see
hello okay so simple web message got
back to me so this is in a format called
Json uh Json is like the uh goto
representation of uh rest API right now
what we are using so if you do not know
Json have a look around Json and Json um
what it represent simply it is a
representation of information okay so if
you look at the noj's uh
website the website that we are seeing
right now this is represented in XML
okay XML and everything if you go to uh
inspect and if you go to source and if
you go to the uh uh current you guys can
see this is a representation let me try
to get it more around here so this is
the representation that we are getting
out of this XML okay this XML represent
this a lot of information is there but
using this uh HTML language we can
render out here but there might be some
styling going on there might be going on
some JavaScript still the representation
is is giving us this page okay likewise
uh the
njs um the
noj um soorry the Json that we what we
are seeing if you go to inspect and you
guys can see this is like past a little
bit but uh uh if I close this and go to
view page Source you guys can see it is
simply a representation like this so the
browser does not how to format Json like
this but we can uh we can just see what
it is sending us back in here I have a
plugin a chrome plugin which uh show
this one as a little bit nicer but if I
show the raow version this is what I'm
getting from the server itself okay so
let me go back to the code and try to
explain what we are trying to do in here
so what we are simply doing is first uh
in the line first line we are importing
we are requiring the express server okay
so we will be creating a server using
Express so in order to use express we
need to First import it okay so the
first line is definition of uh getting
uh Express into our code and there is
more elegant way to uh import this is
also something that you will find
similar so basically like languages like
python uh Java uh we find similar
implementation when we are importing
such you can use the required version it
is also okay in JavaScript world but uh
probably the latest es6 modules will
represent importing like this okay
remember this is also okay but this is
like the old version it say use uh es
module Imports so it will import
something like this so we are basically
saying we are importing Express the the
package we have installed and we are
creating an instance of it okay we are
creating an instance of the express okay
the next thing is uh we are instructing
Express okay we have created the express
app simply if somebody try to get so uh
get in the sense uh get is like what we
call uh rest
operations okay we as I mentioned
earlier we are developing a rest API in
here so if somebody get uh get to this
URL that means we call this as the root
if somebody gets to the root of our
application this function will uh this
function will be executed this is the
function that if somebody comes to the
root of our application this function
will be executed and the function will
contain two things the request and the
response the request is whenever the
user is requesting something it
represent the request and whenever we
want to send something it represent the
response okay so we have the request and
the response all we need to do is we are
not much caring about the request itself
in the response I would say the response
send a Json with this message so I am
responding responding whoever whenever
whenever somebody is coming to the root
of the application I am responding a
Json uh it is going to be representing
like this it's going to have a message
and the message value itself so I'll be
responding a message if somebody comes
to the root of my application okay and
next thing we need to do is we need to
say h okay the application is created
now it need to go like need to uh start
working so that's why we use the listen
uh method that means we need to say okay
we will uh start our application in Port
3,000 so this since this is a web server
web service we'll simply uh have
something in in the uh Port 3,000 you
can use any other Port uh which is
available in your machine uh something
something that is reserved in your
machine like do not use port under 1,24
which are like we consider Reserve ports
like Port 8 443 those things have
different uh meanings different use
cases do not use something like that use
a higher Port like 3,000 or anything
about 3,000 or 2,000
above so we will create express
application and if somebody comes to the
root of our application we will simply
respond with the J L containing this and
it uh and we will start listening on for
3,000 and we can have more API end
points okay we can have more API end
points I would say if somebody comes to
root and in uh message end point so now
the uh end point is different as long as
the the the two point two end points are
not the same value we can have any end
number of end points
points
so I think there is a limit but
technically we can have any um lot of
end points to our use so if somebody
comes to um root of our application or
root of our end points it will save this
if somebody comes to root 4/ message I
will say hello uh hello
users of rest okay so basically a simple
uh if somebody comes to the root they
will get this message and root 4/ I mean
4/ message if somebody comes it the
response will be little bit different so
let's see this in action uh I will
terminate the running application by
hitting contr C and I will run it
okay this is uh this is like when we are
using the express version with es module
so I'll R this back it's going to give
me um turns Express
require Express okay I I'll keep the
same version I might need to do some
package changes so in order to avoid
that as a shortcut I would definitely
use the required uh import section okay
we'll see Import in our next one right
now we will use require as import
mechanism all right let's clear and run
it again no issues right now so if I go
to force you guys can see the force
slice is not there if you put it there
it will be disappeared that's done by
browser so we consider this as the root
so hello randika is sh and if I put for
SL message in here and you guys can see
Hello users of rest okay so we get
different response based on the
different routes that you can go so
there can
be we can generate uh any number of
routes which will corresponding which will
will
correspond the correspond our
application so this is like simple rest
API that we have
generated okay so up until this uh you
guys have any questions with the simple
rest API we have developed any
clarify get you a clarification and move
forward if you do not understand just
let me
know do not think that asking question
is a weaker mind or something that that
you put in that you will be put in
highlight or something like that more
questions that you ask the more
knowledge that you
know okay so so right now let me explain
it one more time so you guys can get the
idea um so right now uh we are trying to
get some message in in our browser okay
so it's going to be represented in Json
so Json is like a
way of uh showing you showing us some
messages or showing us some information
so the the message or the uh information
that we are trying to uh show is
something called message and the message
is going to be this okay so let me um
change the response so say for
instance I would go to endpoint like of
or uh 3,000 run vehicle so in my web
service I will I should have a web
endpoint call R right now you if you
guys go here uh you won't find an
endpoint like this okay you don't find
the end point so let me create an
endpoint which represent the
URL so I will have an endpoint a get
endpoint by default when we are doing a
request is going to be a get request so
the rest end point is going to be Rand
okay the end point is going to be Rand
and whoever comes to this endpoint
whoever comes to this R endpoint will
receive a message whatever in in within
this function itself okay so the message
that I'm going to be showing in here is
um is going to be uh something called
name name okay so it's showing me R and
I would say uh I have something like age
I think I'm 30 not sure I haven't
counted it yet and I will say C and I say
say
Mar so if somebody comes to endpoint
call randika and it will give
information about me something like this
name is going to be randika age going to
be 30 city will be Mark okay so if
somebody comes to this URL the end point
we will get this message as in a Json
format it's going to be a Json format
that we will be seeing this so how I'm
going to run this I'm going to
completely stop the running application
control C and I'm going to run it again
okay now if I go to endpoint Local Host
3,000 as you guys can see I am running
this web server in Port 3000 Port 3000
is where I'm running this application
the port 3000 application will uh run my
express application okay so this express
application has three end points the
root endp Point message endpoint run the
end point okay so if I go to root Local
Host 3,000 root I will get this Local
Host 3,000 message I will get whatever
in this function Local Host randika I
will get whatever in this function as a
Json okay so if I go to Local Host
randika and you guys can see name age
and city is represented to me so this is
a representation of Randa okay so you
can have anything like like what you
have so for example I need
to um I need to show the current time
okay I need to return the current time
and I need to uh return uh say for
example I need
to um return the current country and
everything so I can do that uh so uh let
me create another
Endo my endpoint would be uh time okay
to show the time and the representation
of the time is going to be something
like time and I can show the time by
simply calling new date function so the
time will be represented by new date
that means it will return uh the current
time and I want to represent
country country and I can say Sri [Music]
[Music]
Lanka Sri [Music]
[Music]
Lanka and I'll format my document so it
will look like this so I have an
endpoint called time and the time
endpoint will return the latest time and
the country of so the country will not
change but the time or the date uh the
time in here what we'll see it's going
to be little bit different as we request
because each time when we request it's
going to create a new date and it will
show let's see it in action so you guys
get the idea so we have create an
endpoint call
time I'll stop the application I'll run it
again okay now if I go to an endpoint
call time you get can see the time is uh
this okay so it's going to represent the
date uh and the
time and the Zone okay so remember these
numbers at least these ones at least
these n n
numbers okay and if I refresh again you
guys can see the time changes because
whenever I am requesting whenever I am
requesting it's going to give me the
current time it's going to to give me
the current time so how do I get the
current time by simply calling new date
function or new date class so if I
refresh every time I refresh you guys
can see at least the milliseconds of it
it is changing so we get different time
each time when we refresh or when we
call the class okay so basically what we
are doing is we are creating an endpoint
we are creating an endpoint which will
represent some data if you're going to
Rand the uh endpoint you will get about
information about run if you go to the
time end point you will get something uh
something like the date and everything
it can
be uh
uh uh it can be have it can have
anything that you like it can it can
represent data from a database right now
what we are representing data which is
hardcoded in here okay we are not
getting any data from a database even we
can do that even even okay we will see
that in later on right now we are shown
some Dynamic data and some static data
so the time is at least Dynamic the
country is actually uh static
information okay so we can represent any
information like this okay I have a
question is like
object if we can create more objects
okay so the question is we have
uh app Express in here so what we are
creating is yes it is something similar
to an uh similar to an object it is not
a simple object that we see uh like like
when we are creating a new date yes this
will create a new object but in here we
are instantiating a new Express instance
it is uh something similar to
instantiation object but little bit
different okay so yeah the question is
uh we can have many app expresses we can
have uh multiple uh app Express instance
but it's very rare to have two different
apps in one single application believe
me having one single express application
in this scenario is getting more
complicated than you think okay we can
have several Express instances we can
have listening them on different ports
yes we can do that but that is like
really really bad idea to do it will it
will not be very U what do you call
Simply it won't be able to Simply scale
and everything it won't happen so
basically we will create a one single
express application and we will serve it
under this F if you need need more I
would recommend to have another Express
instance probably an separate
application a separate let's say we want
to have another app we can create app
two and have the same thing do not use
the same port you can't actually use the
same port if you use port 3,000 in one
single application until the program is
terminated this one is blocked okay you
have to use a different port so for
example if you can see that right now I
am using Port 3000 in this application
and if I try to run this again I say not
app.js you guys can say you guys can see
listening address already in use so I
can't run it again because it's already
in use so make sure to change the port
number at least it is not used by
something then you can create another
app instance and run and my
recommendation is do not use two app
instance in here in the same same
application at least uh have to uh
separate uh files so it will make more sense okay yes good good questions uh
sense okay yes good good questions uh any anything you guys need to ask
more um I need your confirmation if all all of you guys get these
all of you guys get these things
oops okay how do we know the reserved ports yes so basically reserved ports
ports yes so basically reserved ports are uh as I mentioned the ports normally
are uh as I mentioned the ports normally we consider Reserve ports up until Port
we consider Reserve ports up until Port uh 1024 if you do a Google search you
uh 1024 if you do a Google search you will get uh Reserve
ports um
OS Port yes normally yes uh from zero to two uh uh 1023 is known as Reserve P so
two uh uh 1023 is known as Reserve P so anything above uh you can use this but
anything above uh you can use this but probably do not use like 10,24 something
probably do not use like 10,24 something like that use a higher port number the
like that use a higher port number the more higher you get you can go but there
more higher you get you can go but there is high upper limit I think 16,000 or
is high upper limit I think 16,000 or something like that so do not use
something like that so do not use Reserve Port these ports will will not
Reserve Port these ports will will not simply the operating system will not
simply the operating system will not allow to run so if I if I go here and
allow to run so if I if I go here and change this to like uh 80 so 80 or
change this to like uh 80 so 80 or something like that and if I try to stop
something like that and if I try to stop this and if I try to run
this and if I try to run this uh think the 80 is not taken at the
this uh think the 80 is not taken at the moment I have allow
moment I have allow it LO
it LO host yeah for for for this machine you
host yeah for for for this machine you get the 80 since I am not using 80 but
get the 80 since I am not using 80 but probably you would not be using a
probably you would not be using a reserved Port okay so you guys can see
reserved Port okay so you guys can see since I'm using Port 80 I do not need to
since I'm using Port 80 I do not need to use even the port 80 over here you can
use even the port 80 over here you can just simply yeah you can simply have
just simply yeah you can simply have that c but if you I'm not sure 443 is
that c but if you I'm not sure 443 is https what we call let me try if I can I
https what we call let me try if I can I get definitely get an error at
get definitely get an error at least
least Port
Port 43 still comes uh let me know a
43 still comes uh let me know a wellknown port
wellknown port like2 be
like2 be S4 still
yeah you do not use these kind of ports you know you can you can't get the hold
you know you can you can't get the hold of it sometimes it works sometimes it
of it sometimes it works sometimes it not because the port 22 is known as the
not because the port 22 is known as the SFTP ports so those ports won be in use
SFTP ports so those ports won be in use so do not use something like well known
so do not use something like well known ones use something like 3,000
ones use something like 3,000 3,33 they're like there other numbers
3,33 they're like there other numbers you guys can play around do not have
you guys can play around do not have like a very small
like a very small number so so wellknown ports uh skip
number so so wellknown ports uh skip those
those things and use a very higher up okay so
things and use a very higher up okay so probably wellknown ports are like like
probably wellknown ports are like like 22 443 80 um there are like different
22 443 80 um there are like different TCP connection based on on those things
TCP connection based on on those things do not use these
things anything else guys
so it's going to differ from the operating system as well some some
operating system as well some some operating system have different uh but
operating system have different uh but but standard wise you you don't try do
but standard wise you you don't try do not try any reserve ports up until
not try any reserve ports up until 1023 good questions yes any other things
1023 good questions yes any other things that you guys need to know before we
the the server in this I did not get the question
correctly is the port used for the as access the service is this
the as access the service is this application maybe you can explain the
application maybe you can explain the question a little bit uh I do not get
question a little bit uh I do not get the question like what you asking right
now uh last chat message I do not I can't understand actually uh
can't understand actually uh so index number I think 10 1048 but
so index number I think 10 1048 but you're asking I'm not getting that
you're asking I'm not getting that please clarify me
please clarify me more okay any other questions
more okay any other questions guys 1048 you can ask if you if you want
guys 1048 you can ask if you if you want you can unmute and
names okay what is the purpose of port number okay so the port number is
number okay so the port number is something like um when you're using a
something like um when you're using a port
port um you don't you don't have any other
um you don't you don't have any other application interfering with your data
application interfering with your data okay so for example uh a certain Port
okay so for example uh a certain Port will only only uh deliver certain
will only only uh deliver certain content Let me Give an example if if you
content Let me Give an example if if you find uh internet as a huge tube okay
find uh internet as a huge tube okay think uh the
think uh the the connections that you have is as a
the connections that you have is as a huge tube okay uh and within that huge
huge tube okay uh and within that huge tube you have different different
tube you have different different smaller tubes which is running on inside
smaller tubes which is running on inside that okay so you when you are sending a
that okay so you when you are sending a certain values in a smaller tube what
certain values in a smaller tube what will happen is the other tubes around it
will happen is the other tubes around it does not know what is the contain is
does not know what is the contain is okay what what you are sending in uh in
okay what what you are sending in uh in a smaller tube does not know or does not
a smaller tube does not know or does not interfere with other other um other
interfere with other other um other other tubes so it's the same scenario in
other tubes so it's the same scenario in here so if you if you have a single
here so if you if you have a single connection and you want to send multiple
connection and you want to send multiple data multiple protocols and uh the by
data multiple protocols and uh the by the way to divide those things is use a
the way to divide those things is use a port so when you're using a port the
port so when you're using a port the data which is
data which is coming uh from one single port is not
coming uh from one single port is not interfering with something else for
interfering with something else for example we have wellknown ports like the
example we have wellknown ports like the SSH ssh we use port 22 SSH is the well
SSH ssh we use port 22 SSH is the well known port for sshing to that means
known port for sshing to that means remote connecting to a machine we use
remote connecting to a machine we use the port 22 for that okay that is like a
the port 22 for that okay that is like a well standard you can use any other Port
well standard you can use any other Port okay with the well known Port is 22 so
okay with the well known Port is 22 so if you you if you're ssing from Port 22
if you you if you're ssing from Port 22 and the wellknown port for serving web
and the wellknown port for serving web application is Port 80 8C Z so you can
application is Port 80 8C Z so you can serve a web page in Port 80 while you
serve a web page in Port 80 while you are sing it in Port 22 so those
are sing it in Port 22 so those different two things do different things
different two things do different things so you you don't not interfere the SSH
so you you don't not interfere the SSH stuff with the HTTP stuff so make the
stuff with the HTTP stuff so make the differences and different port different
differences and different port different ports can have different uh applications
ports can have different uh applications running they can have different uh data
running they can have different uh data going on there so uh the protocols can
going on there so uh the protocols can be different and it's uh it is easy to
be different and it's uh it is easy to manage data in a in a way that they do
manage data in a in a way that they do not conflict with each other okay so
not conflict with each other okay so that's why we use ports so we can Rite
that's why we use ports so we can Rite run uh one single application in Port
run uh one single application in Port 3,000 we can WR we can run another
3,000 we can WR we can run another application in Port 4,200 or anything
application in Port 4,200 or anything above wellknown PS okay so those two
above wellknown PS okay so those two will not get interfere with each other
will not get interfere with each other those those two ports will serve content
those those two ports will serve content in different
in different hope that answer your
yes all good anyone have any other in things to ask so few things that you
things to ask so few things that you guys need to do research on your end
guys need to do research on your end first I might take this as an assignment
first I might take this as an assignment as well uh I'll send it in the
as well uh I'll send it in the group uh what
group uh what is uh
is uh rest
rest API and name for
API and name for rest
rest methods okay the second one
methods okay the second one is
is uh what is Json that one is what is
uh what is Json that one is what is XML okay so do your research
XML okay so do your research and
and find uh find what are these things and
find uh find what are these things and prepare a small assignment on that
prepare a small assignment on that okay all right any more questions yes
okay all right any more questions yes good any more questions that you need to
okay all [Music]
right okay so we we develop a very simple uh rest API using Express and um
simple uh rest API using Express and um using some of the um
using some of the um uh some of the methods only we use the
uh some of the methods only we use the rest API method called get there are
rest API method called get there are other methods while you're doing we will
other methods while you're doing we will find other methods as well learn the
find other methods as well learn the difference that is the rest commands and
difference that is the rest commands and what are the different methods that you
what are the different methods that you can work with Okay so if if if you uh if
can work with Okay so if if if you uh if you're coming to in the industry you as
you're coming to in the industry you as a web developer or maybe a mobile
a web developer or maybe a mobile developer someone else something like
developer someone else something like that you're definitely going to learn
that you're definitely going to learn right in much more detail I mean at
right in much more detail I mean at least you need to interact with this so
least you need to interact with this so better you guys know the um uh things
better you guys know the um uh things behind these uh Technologies so you guys
behind these uh Technologies so you guys get a good
get a good idea um yeah for references part use
idea um yeah for references part use Internet it's the best best I can do um
Internet it's the best best I can do um uh you would probably find um lot of U
uh you would probably find um lot of U information in Internet you guys
information in Internet you guys uh even Wikipedia would
uh even Wikipedia would do okay and uh if you if you need more
do okay and uh if you if you need more uh web Focus one I would probably use W3
uh web Focus one I would probably use W3 schools it has all these
things okay any more questions uh before we move
on so we we create a simple web service okay web
okay web server by creating this simple web
server by creating this simple web server we were able to uh generate few
server we were able to uh generate few end points which is the root end point
end points which is the root end point the message end point randika and time
the message end point randika and time end point so different endpoints give us
end point so different endpoints give us uh different outputs okay and um some
uh different outputs okay and um some all all these uh all these uh endpoints
all all these uh all these uh endpoints give us a
give us a Json uh by default that is like most
Json uh by default that is like most commonly used in rest so in here we are
commonly used in rest so in here we are using Json as well
using Json as well so
so uh uh the the Json output that we are
uh uh the the Json output that we are seeing is different from one to another
seeing is different from one to another that is okay um so you
that is okay um so you guys
guys go go and develop some simple restant
go go and develop some simple restant points like this so this is going to be
points like this so this is going to be very very uh simple one but the problem
very very uh simple one but the problem arise uh when we are developing um uh
arise uh when we are developing um uh when we are developing web
when we are developing web applications it's it's going to be it's
applications it's it's going to be it's going to get really really complicated
going to get really really complicated than this okay so for
than this okay so for example uh when we want when we want to
example uh when we want when we want to uh uh show some data in in a Json format
uh uh show some data in in a Json format it's not going to be something like uh
it's not going to be something like uh We call we call these hard code values
We call we call these hard code values okay the values are uh
okay the values are uh [Music]
[Music] the values that we get when we go to the
the values that we get when we go to the Endo are hardcoded into the source code
Endo are hardcoded into the source code okay it's it's embedded in the source
okay it's it's embedded in the source code but for some reason say for
code but for some reason say for instance we need uh some uh something
instance we need uh some uh something like um something like this information
like um something like this information some information to be fetched from the
some information to be fetched from the database okay we we we can't have those
database okay we we we can't have those everything in here so we need to connect
everything in here so we need to connect to the database and retrieve the
to the database and retrieve the database
database values uh and once we retrieve those
values uh and once we retrieve those values we need to show or we need to uh
values we need to show or we need to uh send it back
send it back so uh pretty simply the application will
so uh pretty simply the application will get complicated enough so we can't
get complicated enough so we can't handle um our request so the database
handle um our request so the database queries going to be there you guys know
queries going to be there you guys know database queries so database queries
database queries so database queries will be there we need to execute those
will be there we need to execute those queries we need to make a database
queries we need to make a database connection and um once the connection
connection and um once the connection once the query is executed we need to
once the query is executed we need to return the
uh we need to return the value there are lot of things going to
value there are lot of things going to add into this application this
add into this application this application is going to get really
application is going to get really really messy really really in a really
really messy really really in a really small time okay so in order to make sure
small time okay so in order to make sure uh that our application can grow okay
uh that our application can grow okay the application can grow and our
the application can grow and our application will have
application will have um our application will
um our application will um application will be able to scale and
um application will be able to scale and you know when the next developer comes
you know when the next developer comes uh they they won't find thousand and
uh they they won't find thousand and points within the same application and
points within the same application and we have written written a good amount of
we have written written a good amount of test cases to test our application so
test cases to test our application so this uh this way of coding this what we
this uh this way of coding this what we call the architecture the this one that
call the architecture the this one that the simple one that we have come come
the simple one that we have come come across would not suffice this this
across would not suffice this this application will simply fail okay so
application will simply fail okay so what we can do is we can develop an
what we can do is we can develop an architecture we can develop an
architecture we can develop an architecture that will be
architecture that will be less uh complicated okay remember these
less uh complicated okay remember these by applying an architecture it doesn't
by applying an architecture it doesn't not mean everything that we have is
not mean everything that we have is going to be uh it's going to be
going to be uh it's going to be [Music]
[Music] um it's going to be solved
um it's going to be solved okay by simply applying an software
okay by simply applying an software architecture it will reduce the
architecture it will reduce the complexity of course it will reduce the
complexity of course it will reduce the complexity and it uh it will um it will
complexity and it uh it will um it will be understand by the most majority of
be understand by the most majority of our uh our users or our developers so
our uh our users or our developers so for example if we develop an applic
for example if we develop an applic appliation like this this might be our
appliation like this this might be our own style okay this I can develop an
own style okay this I can develop an application like this I can I have
application like this I can I have everything working fine okay if I can
everything working fine okay if I can manage th000 end points like this yes
manage th000 end points like this yes that is fine but the problem is if I
that is fine but the problem is if I want to give this source code to someone
want to give this source code to someone else will that person understand what
else will that person understand what I'm trying to do okay will that person
I'm trying to do okay will that person will have a hard time understanding the
will have a hard time understanding the code itself so by providing a simple
code itself so by providing a simple architecture by providing a simple
architecture by providing a simple methodology to that what will happen is
methodology to that what will happen is it
it will it will guarantee that okay
will it will guarantee that okay everybody knows this is how it should
everybody knows this is how it should get done okay this is a methodology that
get done okay this is a methodology that everybody is following so the next
everybody is following so the next person would come and say ah okay I know
person would come and say ah okay I know this methodology I have to just
this methodology I have to just Implement using these things so and an
Implement using these things so and an architecture gives us uh guidance or we
architecture gives us uh guidance or we it gives us proper structure and
it gives us proper structure and uh uh proper way of doing things but um
uh uh proper way of doing things but um remember a software architecture the way
remember a software architecture the way of we organize our code the way of we
of we organize our code the way of we going to implement such and such a thing
going to implement such and such a thing is going to be different on the uh
is going to be different on the uh different uh project or different uh
different uh project or different uh application that we are developing okay
application that we are developing okay so for an web application we can have a
so for an web application we can have a different architecture for a mobile
different architecture for a mobile application we can have a different
application we can have a different architecture that's because the purpose
architecture that's because the purpose of the application is different from one
of the application is different from one one one to another so mobile application
one one to another so mobile application have different restrictions different
have different restrictions different mechanisms how they works and different
mechanisms how they works and different limitations with the resources and all a
limitations with the resources and all a web a web application such as rest API
web a web application such as rest API that we have developed it's going to be
that we have developed it's going to be running on a server we have certain
running on a server we have certain server limitations we have certain uh
server limitations we have certain uh database limitation and all all sort of
database limitation and all all sort of things so based on the application that
things so based on the application that we're going to be developing based on
we're going to be developing based on the technologies that we are having the
the technologies that we are having the architecture of the program will differ
architecture of the program will differ but most commonly with web
but most commonly with web applications right now when we are
applications right now when we are developing a web
developing a web application uh we find that the NT
application uh we find that the NT architecture or 3D architecture at least
architecture or 3D architecture at least works better with our uh with our code
works better with our uh with our code organization the NTI architecture if you
organization the NTI architecture if you write uh an NTI architecture
write uh an NTI architecture application it would make our life easy
application it would make our life easy and if somebody comes tomorrow and join
and if somebody comes tomorrow and join our team and they we can say okay uh our
our team and they we can say okay uh our application is following n architecture
application is following n architecture and we all agree upon how n architecture
and we all agree upon how n architecture should work okay we'll certain we will
should work okay we'll certain we will learn certain things in N architecture
learn certain things in N architecture so next time when you go to Industry and
so next time when you go to Industry and you guys can ask okay uh we have a web
you guys can ask okay uh we have a web application you can ask okay good what
application you can ask okay good what is the architecture that we using so
is the architecture that we using so they might say oh we are using n
they might say oh we are using n architecture so you don't need to know
architecture so you don't need to know okay n architecture by by n architecture
okay n architecture by by n architecture we have certain component we have such
we have certain component we have such and such then you will easily understand
and such then you will easily understand what what they are talking about okay
what what they are talking about okay the software architecture is something
the software architecture is something like that it is a well-known practices
like that it is a well-known practices well-known things that will
well-known things that will overcome overcome the uh common problems
overcome overcome the uh common problems that we are having so for example we all
that we are having so for example we all know okay when we are talking about n
know okay when we are talking about n architecture the whole whole development
architecture the whole whole development teams have the idea of okay when we are
teams have the idea of okay when we are developing this application there will
developing this application there will will be this this this and we have to
will be this this this and we have to follow those things so it it
follow those things so it it won't it won't make you an outcast or
won't it won't make you an outcast or the project uh leads Outcast so we know
the project uh leads Outcast so we know okay when we are developing this
okay when we are developing this application we are following these
application we are following these principles we are we are at this point
principles we are we are at this point and we are using these things okay so in
and we are using these things okay so in as I mentioned earlier for web
as I mentioned earlier for web applications so simple
applications so simple applications uh we find the NTI
applications uh we find the NTI architecture to be working perfectly
architecture to be working perfectly okay as I mentioned
okay as I mentioned earlier n architecture will not be very
earlier n architecture will not be very suitable for our mobile application we
suitable for our mobile application we we we um sometimes it might work
we we um sometimes it might work sometimes it not there are different
sometimes it not there are different architectural patterns that we can use
architectural patterns that we can use but for stus the simplest form uh
but for stus the simplest form uh developing a simple web application we
developing a simple web application we will talk about the n architecture okay
will talk about the n architecture okay so any questions uh about what we have
so any questions uh about what we have discussed why we need an architectural
discussed why we need an architectural pattern and what sort of things it um uh
pattern and what sort of things it um uh it's it try to resolve it's trying uh
it's it try to resolve it's trying uh the basically an architecture pattern we
the basically an architecture pattern we give
give formal uh formal structure to our
formal uh formal structure to our project and all the all the the software
project and all the all the the software team will be
team will be in uh in in sync up with the
in uh in in sync up with the Technologies and when you when you want
Technologies and when you when you want to when you want to learn uh the way how
to when you want to learn uh the way how software is
software is organized so you guys can refer that
organized so you guys can refer that architect and add up to that so there
architect and add up to that so there are a lot of Architects going on
are a lot of Architects going on remember based on the project those
remember based on the project those Architects can be different okay so any
um okay definitely this will be uploaded no
questions okay hope not okay let's see so we'll move into the NTI architecture
so we'll move into the NTI architecture so you guys can see in the sample
so you guys can see in the sample application the sample express
application the sample express application that we have
application that we have created um we have several things things
created um we have several things things okay we have several things so you guys
okay we have several things so you guys can see um we are accepting uh a request
can see um we are accepting uh a request okay we are accepting a request the
okay we are accepting a request the client is asking something and we are
client is asking something and we are responding to that so we have what we
responding to that so we have what we call a request and we have something
call a request and we have something called a response okay
called a response okay so uh some request some request can be
so uh some request some request can be uh can be group
uh can be group some request represent the same uh same
some request represent the same uh same set
set of uh values for example in this uh in
of uh values for example in this uh in this uh in this scenario we do not see
this uh in this scenario we do not see uh strikingly similar things so all
uh strikingly similar things so all these things are like several uh several
these things are like several uh several different things but when we are working
different things but when we are working with um a good uh applic ific ation some
with um a good uh applic ific ation some features have typed together some
features have typed together some features will um have different purposes
features will um have different purposes okay for
okay for example um we call uh normally we call
example um we call uh normally we call these things as crud operations okay
these things as crud operations okay crud operations we call these things so
crud operations we call these things so uh the crud operations stick together so
uh the crud operations stick together so what do you understand by a crud
what do you understand by a crud operation so in CR c r u we call this
operation so in CR c r u we call this create uh read update delet interest
create uh read update delet interest okay so that's that's the basic of uh
okay so that's that's the basic of uh what what it stand for at least uh crud
what what it stand for at least uh crud okay do uh uh do a simple uh Implement
okay do uh uh do a simple uh Implement look at around crud so crud stand for
look at around crud so crud stand for create read update and delete so uh in a
create read update and delete so uh in a system say for example we want to
system say for example we want to develop a simple user management system
develop a simple user management system we want to develop a simple user
we want to develop a simple user management system in that user
management system in that user management system we need to able to
management system we need to able to create users so for example uh we want
create users so for example uh we want to uh create a user with the name email
to uh create a user with the name email that's it okay we do not need anything
that's it okay we do not need anything else within our system what it will do
else within our system what it will do is create a user with a user
is create a user with a user name um username or uh
name um username or uh email uh on that we call we we need to
email uh on that we call we we need to create the user okay that's we call the
create the user okay that's we call the create
create operation and some sometimes back
operation and some sometimes back sometimes later we need to read all the
sometimes later we need to read all the users that means we need to get all the
users that means we need to get all the users within our system let's say for
users within our system let's say for example now we have 100 registered
example now we have 100 registered people we need to get those 100 people
people we need to get those 100 people okay that is what we called a read
okay that is what we called a read operation okay sometimes we do not need
operation okay sometimes we do not need the 100 uh 100 users but we need a
the 100 uh 100 users but we need a certain user one single certain user
certain user one single certain user which have the uh let's say which have
which have the uh let's say which have the email uh example.com okay we need a
the email uh example.com okay we need a one single particular user which has one
one single particular user which has one single we one single user we need to
single we one single user we need to read it back from the system so that we
read it back from the system so that we call a read we can have multiple users
call a read we can have multiple users or we can have one single user either
or we can have one single user either way we going to be reading users from
way we going to be reading users from the system and there will be other
the system and there will be other operations such as update operations
operations such as update operations what we call uh uh update request so
what we call uh uh update request so sometimes uh some sometimes we when we
sometimes uh some sometimes we when we are working with the system uh we need
are working with the system uh we need to update a particular users information
to update a particular users information for example a user can have a first name
for example a user can have a first name and a last last name and we need for
and a last last name and we need for some reason they have either misfill the
some reason they have either misfill the first name and we need to update that
first name and we need to update that record we we do not need to create a new
record we we do not need to create a new record okay we need to create we need to
record okay we need to create we need to update an existing record so we call
update an existing record so we call that a update request and finally we
that a update request and finally we have something like a delete request
have something like a delete request which will uh Delete the record from
which will uh Delete the record from from our application okay so that is
from our application okay so that is what we call a delete request
what we call a delete request so these three uh these four request
so these three uh these four request types are mostly common within a system
types are mostly common within a system that you you guys will develop so this
that you you guys will develop so this is very common in web application so we
is very common in web application so we call this crud operations so we will
call this crud operations so we will create a crud operation that is only for
create a crud operation that is only for users we can create users read users
users we can create users read users update users and delete users and we can
update users and delete users and we can have Crow operations for another thing
have Crow operations for another thing for example uh we we also want to
for example uh we we also want to manage uh let's
manage uh let's say uh schools okay so we need to create
say uh schools okay so we need to create a school we need to read an school name
a school we need to read an school name or information about one single school
or information about one single school or more than one single school so we
or more than one single school so we need to read we need to update some
need to read we need to update some certain information and we need to
certain information and we need to sometimes we need to delete okay the C
sometimes we need to delete okay the C is not like always going to be the all
is not like always going to be the all the SP things going to be there but
the SP things going to be there but basically when we are developing an
basically when we are developing an application we Implement all those craft
application we Implement all those craft operations okay so when we develop uh
operations okay so when we develop uh such a thing so we have the user C and
such a thing so we have the user C and screw crab and think about another thing
screw crab and think about another thing like we need to manage teachers okay so
like we need to manage teachers okay so the teachers C so so we have teacher
the teachers C so so we have teacher create teacher reads teacher update
create teacher reads teacher update teacher delete so you guys can see in a
teacher delete so you guys can see in a very complex system uh we will have lot
very complex system uh we will have lot of CR operations not only CR operations
of CR operations not only CR operations there will be some actions as well so we
there will be some actions as well so we will definitely we'll look into actions
will definitely we'll look into actions later on but for now we will simply look
later on but for now we will simply look at hard operations okay so when we are
at hard operations okay so when we are when we when we talk about the user use
when we when we talk about the user use head for CR operations okay let's uh for
head for CR operations okay let's uh for the for those four CR operations we will
the for those four CR operations we will have four end points okay so right now
have four end points okay so right now we have one single end point in here
we have one single end point in here another one here and another one here so
another one here and another one here so we have totally four end points but all
we have totally four end points but all are read operations these are what we
are read operations these are what we call read operation get is a read
call read operation get is a read operation but for user you can have four
operation but for user you can have four different uh um four different uh
different uh um four different uh endpoints one for create one for read
endpoints one for create one for read one for update one for delete okay so we
one for update one for delete okay so we guys you guys can see a single user will
guys you guys can see a single user will have four end points at least four end
have four end points at least four end points and uh school can have four end
points and uh school can have four end points and this
points and this file uh which handle all these uh all
file uh which handle all these uh all these request is going to get bigger and
these request is going to get bigger and bigger okay so at for four for for
bigger okay so at for four for for operations we have we we will add uh for
operations we have we we will add uh for one uh type we will have four so think
one uh type we will have four so think about we in a pro professional system
about we in a pro professional system normally it contains like um 10 to 20 uh
normally it contains like um 10 to 20 uh of such things then it will explode the
of such things then it will explode the file will not be able you can't even
file will not be able you can't even find whatever you need in the single
find whatever you need in the single file so uh what we will do what we need
file so uh what we will do what we need to do is we need to separate things we
to do is we need to separate things we need to separate okay so when we are
need to separate okay so when we are talking about user user will have its
talking about user user will have its own Crut uh operations when we talking
own Crut uh operations when we talking about the school it it school will have
about the school it it school will have a separate C operation file and so list
a separate C operation file and so list goes on so we will be developing such
goes on so we will be developing such application so we we would have the all
application so we we would have the all the C end points in the different
the C end points in the different locations okay okay
locations okay okay so uh that is one thing the C end points
so uh that is one thing the C end points the end points what we have
the end points what we have discussed and the next thing that we be
discussed and the next thing that we be that would that uh that requires is the
that would that uh that requires is the logic behind it okay the logic behind it
logic behind it okay the logic behind it so some something in here we are simply
so some something in here we are simply returning all all these things are uh
returning all all these things are uh just simply uh showing a showing a value
just simply uh showing a showing a value but in
but in reality what will happen is we we can't
reality what will happen is we we can't have such uh simple get test that means
have such uh simple get test that means we are not going to Simply show these
we are not going to Simply show these values by hardcoding this we will
values by hardcoding this we will definitely talk to a database okay we
definitely talk to a database okay we will definitely need some operations to
will definitely need some operations to happen Okay so for
happen Okay so for example uh we want to we want to
example uh we want to we want to delete uh a school okay we want to
delete uh a school okay we want to delete a school in our system there will
delete a school in our system there will be certain rules that we need to follow
be certain rules that we need to follow you can't just delete uh you can't just
you can't just delete uh you can't just delete um school from the system you
delete um school from the system you might need special permission if you are
might need special permission if you are doing such a thing okay you can't just
doing such a thing okay you can't just anybody comes and delete delete a school
anybody comes and delete delete a school that system would not be a really good
that system would not be a really good one sometimes uh if you want to delete
one sometimes uh if you want to delete uh if you want to delete such important
uh if you want to delete such important record you need permissions sometimes
record you need permissions sometimes you you you will uh as two some two
you you you will uh as two some two people should vote on it once they have
people should vote on it once they have done the voting then you can delete that
done the voting then you can delete that that's kind of what we call Logics going
that's kind of what we call Logics going to be there we call those things logic
to be there we call those things logic in system like this we call those things
in system like this we call those things as business logic okay when we want to
as business logic okay when we want to operate something we want when we want
operate something we want when we want to do something we we will have
to do something we we will have something called a business Logics okay
something called a business Logics okay say for instance that logic should be
say for instance that logic should be implemented in here as well so somebody
implemented in here as well so somebody send a delete request and delete request
send a delete request and delete request need to be going through some business
need to be going through some business Logics and you need to check all those
Logics and you need to check all those Logics and everything and this file what
Logics and everything and this file what will happen all those Logics going to be
will happen all those Logics going to be within this simple file this file will
within this simple file this file will explod okay and when somebody is looking
explod okay and when somebody is looking at this file the file is going to be
at this file the file is going to be like 10,000 or 20,000 long and it will
like 10,000 or 20,000 long and it will not make sense to look like look into a
not make sense to look like look into a hinge file like
that all right so what we will do is we rather than writing everything in one
rather than writing everything in one single file or one single location we
single file or one single location we will move the business logic into a
will move the business logic into a separate file or we call a separate
separate file or we call a separate layer okay so all the request that are
layer okay so all the request that are coming the
coming the request that can be a read request
request that can be a read request update request delete request or any CR
update request delete request or any CR request so all the request that is
request so all the request that is coming will be handled by a a single
coming will be handled by a a single layer okay all the request handling will
layer okay all the request handling will be done by a single layer and once that
be done by a single layer and once that layer get the message the business logic
layer get the message the business logic will be handled in a separate layer okay
will be handled in a separate layer okay it will be handle in a separate layer so
it will be handle in a separate layer so why we are layering these things the
why we are layering these things the first thing is the complexity will grow
first thing is the complexity will grow okay everything if you put everything in
okay everything if you put everything in one single one single file one single
one single one single file one single layer the layer will really be uh really
layer the layer will really be uh really really will get big and you can't have
really will get big and you can't have all these Logics and everything in one
all these Logics and everything in one single file it's hard to read okay so
single file it's hard to read okay so what we'll do is all the requests that
what we'll do is all the requests that we are getting will be in one single
we are getting will be in one single layer
layer and once the request is receiv received
and once the request is receiv received to us the business logic will be in a
to us the business logic will be in a different layer okay the business logic
different layer okay the business logic will be in a different layer okay so the
will be in a different layer okay so the business logic when we when we move the
business logic when we when we move the business logic to a different layer the
business logic to a different layer the business logic might
business logic might need uh something uh from
need uh something uh from another uh another place for example in
another uh another place for example in order to in order to uh get in order to
order to in order to uh get in order to create uh in order to create a single
create uh in order to create a single single user or something like that the
single user or something like that the business logic need to talk to a
business logic need to talk to a database we need to talk to a database
database we need to talk to a database in a scenario where we want to talk to a
in a scenario where we want to talk to a database then uh the database
database then uh the database connections and everything should be in
connections and everything should be in uh in that business logic so that's
uh in that business logic so that's going to crowd the business logic layer
going to crowd the business logic layer so in order to access
so in order to access databases anything related to database
databases anything related to database we separate the data layer the data
we separate the data layer the data communication layer especially with the
communication layer especially with the database or another service we separate
database or another service we separate another layer out of the business logic
another layer out of the business logic to a data layer so we have three layers
to a data layer so we have three layers now the first one is the request layer
now the first one is the request layer second one is the business logic layer
second one is the business logic layer third one is the data layer so any
third one is the data layer so any request coming in we will first
request coming in we will first encounter with the request layer
encounter with the request layer anything that need to be calculated any
anything that need to be calculated any business logic need to be happened we
business logic need to be happened we will do it in the uh business logic
will do it in the uh business logic layer and we have a third layer which
layer and we have a third layer which will be accessing all those data okay so
will be accessing all those data okay so you guys can see three tiers the request
you guys can see three tiers the request tier distance logic and the data okay so
tier distance logic and the data okay so that's how a three tier architecture
that's how a three tier architecture representation happens so we have three
representation happens so we have three tiers request business logic and model
tiers request business logic and model or the database
or the database to so this is like the common
to so this is like the common architecture pattern that you guys can
architecture pattern that you guys can use okay it is only three layers but it
use okay it is only three layers but it is not limited to three as I mentioned
is not limited to three as I mentioned earlier the architectural patterns the N
earlier the architectural patterns the N architecture pattern n okay the word n
architecture pattern n okay the word n represent any number but for more most
represent any number but for more most common problems that you will see today
common problems that you will see today with um with uh applications such as web
with um with uh applications such as web application three tier would be enough
application three tier would be enough okay I'm not saying it is always going
okay I'm not saying it is always going to be the case three tiers will be
to be the case three tiers will be enough if you want more layers of course
enough if you want more layers of course you can add say for example your
you can add say for example your business logic is really complex okay
business logic is really complex okay the business logic is really complex in
the business logic is really complex in in a case like that you can divide the
in a case like that you can divide the business logic into
business logic into two or three layers so that will add
two or three layers so that will add more layers in between okay it is not
more layers in between okay it is not limited to three but you can have
limited to three but you can have multiple layers okay depending on your
multiple layers okay depending on your project and it is it is
project and it is it is complexity so the request layer normally
complexity so the request layer normally stays around with one layer that is that
stays around with one layer that is that is like uh that is like normal but as I
is like uh that is like normal but as I mentioned earlier it is not limited to
mentioned earlier it is not limited to having one single layer for handling
having one single layer for handling request it it can have multiple layers
request it it can have multiple layers that is also fine this logic as I
that is also fine this logic as I mentioned earlier if it is very complex
mentioned earlier if it is very complex we separate the business logic into
we separate the business logic into separate layers data layer is also there
separate layers data layer is also there normally we can have many more layers
normally we can have many more layers okay but simply there will be three
okay but simply there will be three layers as most you sometimes somebody
layers as most you sometimes somebody can use two layers if they want but a
can use two layers if they want but a recommendation for a web application my
recommendation for a web application my recommendation at least what of what
recommendation at least what of what most users will get is a three tier or
most users will get is a three tier or three uh three tier architecture right
three uh three tier architecture right now we have all those three tiers in one
now we have all those three tiers in one single file okay so we have the request
single file okay so we have the request this is the request endpoint and we have
this is the request endpoint and we have our business logic in here since we do
our business logic in here since we do not have a data layer the data layer is
not have a data layer the data layer is also in here okay so all these three
also in here okay so all these three three layers three things are within one
three layers three things are within one single request so so this is considered
single request so so this is considered to be bad practice let me tell you why
to be bad practice let me tell you why this is bad after we Implement a sample
this is bad after we Implement a sample application using 3ar architecture okay
application using 3ar architecture okay so this is uh this is working okay this
so this is uh this is working okay this is working perfectly anyone can anyone
is working perfectly anyone can anyone can code like this a project can run
can code like this a project can run like this yes you can but uh on the long
like this yes you can but uh on the long term long run this would definitely give
term long run this would definitely give us headache Okay so so we have the
us headache Okay so so we have the request layer we have the uh business
request layer we have the uh business logic layer and we have the data layer
logic layer and we have the data layer all in one single location we will try
all in one single location we will try to tear this up into three different
to tear this up into three different layers and see how we can work with that
layers and see how we can work with that okay so anyone have any questions um
okay so anyone have any questions um with the three tiers the request
with the three tiers the request distance logic and the data anyone have
distance logic and the data anyone have any questions regarding those three
any questions regarding those three layers anything that need to be
layers anything that need to be clarified
okay suppose everybody got uh the DTs that we'll be working on and we will see
that we'll be working on and we will see how we can create a simple web
how we can create a simple web application that represent this 3s okay
application that represent this 3s okay so as you guys can see I used a very
so as you guys can see I used a very simple um single
simple um single um single file the appjs file to create
um single file the appjs file to create a simple application that as as
a simple application that as as mentioned
mentioned earlier nowadays we do not uh develop
earlier nowadays we do not uh develop application like this okay so you need
application like this okay so you need to find all the packages we need to have
to find all the packages we need to have all these things um there are like
all these things um there are like certain other aspect of program that we
certain other aspect of program that we need to work on like certainly the
need to work on like certainly the structure of the program how we going to
structure of the program how we going to structure it okay and what are the um
structure it okay and what are the um what are the testing Frameworks of
what are the testing Frameworks of course our code need to be tested okay
course our code need to be tested okay so what is the testing framework that we
so what is the testing framework that we going to use and how we going to set up
going to use and how we going to set up within our
within our program and what are the things that we
program and what are the things that we that we will be using uh to deploy this
that we will be using uh to deploy this okay so all those things are done over
okay so all those things are done over and over and over again we come to a
and over and over again we come to a what we call a template okay a template
what we call a template okay a template that we can that we can use to or to
that we can that we can use to or to start Kickstart our project okay rather
start Kickstart our project okay rather than putting all the de dependencies all
than putting all the de dependencies all the testing Frameworks and all the
the testing Frameworks and all the building script and everything you don't
building script and everything you don't need to worry all this all this from
need to worry all this all this from scratch what we can do is we can use a
scratch what we can do is we can use a code
code generation uh tool that will help us to
generation uh tool that will help us to create an application so that we don't
create an application so that we don't know to do the heavy lifting when we are
know to do the heavy lifting when we are creating a file so that's what I use uh
creating a file so that's what I use uh in
in here
here uh we use the program called
uh we use the program called uh
uh um We call we use the program called NX
um We call we use the program called NX okay the NX is a tool that we can boost
okay the NX is a tool that we can boost up our application that we can create an
up our application that we can create an application so we don't have to create
application so we don't have to create in from scratch okay so in we first we
in from scratch okay so in we first we need to install NX like we did injs we
need to install NX like we did injs we need to install NX okay or we can use NX
need to install NX okay or we can use NX uh NX based simple tools that we can um
uh NX based simple tools that we can um that we can create the application let
that we can create the application let me um
me um okay
okay let me stop the current application I will see the
I will see the back so in order to create uh an NX
back so in order to create uh an NX application as I mentioned earlier there
application as I mentioned earlier there is the website called NX Dev okay so you
is the website called NX Dev okay so you can create a simple workspace that means
can create a simple workspace that means a simple project uh using um this
a simple project uh using um this command so you can install this npx
command so you can install this npx create NX workspace command in order to
create NX workspace command in order to create a new
create a new Fresh uh fresh web web um web
Fresh uh fresh web web um web application okay so what I did was I use
application okay so what I did was I use this command npx create workspace at
this command npx create workspace at latest that means we I am going to
latest that means we I am going to create a new workspace and I'm going to
create a new workspace and I'm going to name it
name it SF SF that is the workspace name that
SF SF that is the workspace name that can that's think as the project name
can that's think as the project name that that I'm giving for this okay so
that that I'm giving for this okay so I'm going to give that name
I'm going to give that name and by using this it will ask some basic
and by using this it will ask some basic questions what are the Frameworks and
questions what are the Frameworks and all I think we have already covered if
all I think we have already covered if you want to go back and see the video
you want to go back and see the video once again basically it will create a
once again basically it will create a simple
simple application that is
application that is uh close
one close window I don't not need this yes that is this application you guys
yes that is this application you guys can see there are all I mean don't get
can see there are all I mean don't get overwhelmed by all the things that you
overwhelmed by all the things that you see it in here basically it it has set
see it in here basically it it has set up a simple web application to us okay
up a simple web application to us okay simple very simple web application with
simple very simple web application with all the uh testing Frameworks it's all
all the uh testing Frameworks it's all the basic starting point for application
the basic starting point for application and all the dependencies and everything
and all the dependencies and everything to run our project okay so um there are
to run our project okay so um there are a lot of uh prebuilds things uh done for
a lot of uh prebuilds things uh done for us especially with the you know when we
us especially with the you know when we when we are done with the application we
when we are done with the application we need to build this application this is
need to build this application this is the source code once we need to uh once
the source code once we need to uh once once we are done with the source code we
once we are done with the source code we need to uh run it somewhere before we
need to uh run it somewhere before we run it we need to build it so we have
run it we need to build it so we have the build script running we have the
the build script running we have the developments um script uh de script are
developments um script uh de script are there building script are there testing
there building script are there testing script are there so basically a simple
script are there so basically a simple web application is created for us by by
web application is created for us by by simply using those uh code generation
simply using those uh code generation tools so first thing that we need to
tools so first thing that we need to look at is this package Json okay as you
look at is this package Json okay as you guys can remember with the express one
guys can remember with the express one so we are not seeing Express directly
so we are not seeing Express directly but if you go to to njs C and something
but if you go to to njs C and something like that you would would find Express
like that you would would find Express bu deep behind them so there are other
bu deep behind them so there are other libraries that we are using or packages
libraries that we are using or packages that we are using and there are de de
that we are using and there are de de packages that we are using that means
packages that we are using that means while developing we will be using these
while developing we will be using these packages but when we want to deploy
packages but when we want to deploy these things these are no longer valid
these things these are no longer valid we do not need these things in the
we do not need these things in the running application so for
running application so for example um we have testing Frameworks
example um we have testing Frameworks right we will test our program while we
right we will test our program while we are building it while we are in the
are building it while we are in the development place okay once we
development place okay once we developments are done once we want to go
developments are done once we want to go to a hosting server and once we want to
to a hosting server and once we want to share this with the world we do not need
share this with the world we do not need the uh tools that we use while we are
the uh tools that we use while we are testing the frame testing the
testing the frame testing the application so we would
application so we would have we would have left left down all
have we would have left left down all the test T in stuff um while we are
the test T in stuff um while we are building the application after we build
building the application after we build it we do not use the testing libraries
it we do not use the testing libraries so that's why we have two dependencies
so that's why we have two dependencies type uh the D dependencies which
type uh the D dependencies which represent uh the dependencies that we'll
represent uh the dependencies that we'll be using while we are developing and
be using while we are developing and dependencies so these are dependencies
dependencies so these are dependencies we need in order to run and develop at
we need in order to run and develop at the same time okay so these are
the same time okay so these are development time need
development time need and these are on time needed okay
and these are on time needed okay so we will not look into these libraries
so we will not look into these libraries we we probably won't be looking more
we we probably won't be looking more into this unless we need to add a
into this unless we need to add a certain certain functionality to our
certain certain functionality to our application for example if you want to
application for example if you want to add database connectivity then we will
add database connectivity then we will install a certain package that we will
install a certain package that we will be using okay we will see that uh in a
be using okay we will see that uh in a moment right now
moment right now uh we'll be we'll be focusing on uh
uh we'll be we'll be focusing on uh getting the N architecture and running
getting the N architecture and running it once again okay so in order to get uh
it once again okay so in order to get uh uh the application structure so we need
uh the application structure so we need to know the package Json we can have a
to know the package Json we can have a look around it and the most important
look around it and the most important folder is going to be this SRC de okay
folder is going to be this SRC de okay so
so SRC stand for Source at the the source
SRC stand for Source at the the source code of our application and inside there
code of our application and inside there are few files the main main file which
are few files the main main file which is something like the adjs file that we
is something like the adjs file that we have seen earlier on
have seen earlier on and probably you will find something
and probably you will find something similar the app directory and we will
similar the app directory and we will have the listen Port thing so it's going
have the listen Port thing so it's going to also run on Port
to also run on Port 3000 okay so we we can also while we are
3000 okay so we we can also while we are running we can change that but if we if
running we can change that but if we if you do not specify something it's
you do not specify something it's automatically going to run on Port 3,000
automatically going to run on Port 3,000 okay so this is like do not worry about
okay so this is like do not worry about all these uh Global Prix and everything
all these uh Global Prix and everything which uh which and the bootstrap methods
which uh which and the bootstrap methods all these things just think uh when we
all these things just think uh when we run this application it's going to start
run this application it's going to start a web service on to 3,000 okay you can
a web service on to 3,000 okay you can have look around these things in in
have look around these things in in later on
later on right now we are running an application
right now we are running an application with Pro 3,000 and uh you guys can
with Pro 3,000 and uh you guys can remember the end points that we had on
remember the end points that we had on the njs application right now uh as a as
the njs application right now uh as a as a good practice we uh we
a good practice we uh we have uh endpoint prefix uh with all the
have uh endpoint prefix uh with all the apis that that means we I'll show you
apis that that means we I'll show you that means if you if you have endpoint
that means if you if you have endpoint call message by default it will it will
call message by default it will it will be it will be Rewritten to API message
be it will be Rewritten to API message if you have an endpoint called user by
if you have an endpoint called user by default it will be ritten to API users
default it will be ritten to API users okay so that that is something uh the
okay so that that is something uh the community follows when we are developing
community follows when we are developing an rest API we normally have the prefix
an rest API we normally have the prefix called API in front of that okay so when
called API in front of that okay so when we run this application it will uh start
we run this application it will uh start it will start application in code 3,000
it will start application in code 3,000 okay so let me run this application
okay so let me run this application simply I will I will um I will go to the
simply I will I will um I will go to the directory uh from the terminal where I
directory uh from the terminal where I start the application so uh it is
start the application so uh it is in uh s swt so this is the location that
in uh s swt so this is the location that I have choose uh the project right now
I have choose uh the project right now it is in the TMP and SF sft directory it
it is in the TMP and SF sft directory it can be within your programs or
can be within your programs or documents projects whatever the location
documents projects whatever the location that you say so basically uh go to
that you say so basically uh go to your terminal or command line uh open
your terminal or command line uh open the command line where your project is
the command line where your project is there so how do you know that is the
there so how do you know that is the same directory so you guys can see the
same directory so you guys can see the package Jon okay if you like try to
package Jon okay if you like try to explore it and if you see the package
explore it and if you see the package Jon right there then that that is that
Jon right there then that that is that means you are in the correct location
means you are in the correct location okay make sure the packages and or the
okay make sure the packages and or the at least what whatever the files that
at least what whatever the files that you have seen is visible that means you
you have seen is visible that means you are in the correct location okay so in
are in the correct location okay so in order to run this application like what
order to run this application like what we did in the earlier on we we have
we did in the earlier on we we have certain other things uh uh prepared for
certain other things uh uh prepared for us especially what we call a hot preload
us especially what we call a hot preload and there are certain things uh we we we
and there are certain things uh we we we have already configured in this so if
have already configured in this so if you guys can remember when I write the
you guys can remember when I write the next year's
next year's application uh if I do a change I need
application uh if I do a change I need to stop and I need to run it again and
to stop and I need to run it again and uh if I do a simple modification on my
uh if I do a simple modification on my source code I need to stop it and run it
source code I need to stop it and run it again but uh with the with this project
again but uh with the with this project setup that we have come across we do not
setup that we have come across we do not need to do that whenever we do a project
need to do that whenever we do a project uh when we do a project change and we
uh when we do a project change and we save it and it will be automatically
save it and it will be automatically reload for us we don't need need to
reload for us we don't need need to reload our servers we do not need to
reload our servers we do not need to stop or anything like that we do our
stop or anything like that we do our coding we save it and it will be
coding we save it and it will be automatically reloaded okay so you don't
automatically reloaded okay so you don't have to stop every time and go back and
have to stop every time and go back and do those things so everything is set up
do those things so everything is set up for us we don't want to worry about that
for us we don't want to worry about that we'll simply try to run this application
we'll simply try to run this application so we can run these application by by
so we can run these application by by simply looking at one single command
simply looking at one single command under the package H Json file you'll
under the package H Json file you'll find scripts okay these scripts are what
find scripts okay these scripts are what able to run this application so in order
able to run this application so in order to run there is the commands might be
to run there is the commands might be different but in in this in this in this
different but in in this in this in this example or in this project we can see
example or in this project we can see the start script that means we will be
the start script that means we will be starting our server then we there will
starting our server then we there will be build script that means it will build
be build script that means it will build our build our application and there test
our build our application and there test script that means it will test our
script that means it will test our application so the name implies what it
application so the name implies what it does so if I want to start the
does so if I want to start the application I can run this script okay
application I can run this script okay so simply I can uh run by npm start
so simply I can uh run by npm start command okay if I run if I run npm start
command okay if I run if I run npm start the application will start and if I want
the application will start and if I want to build I can uh run this script in
to build I can uh run this script in different way okay so if I want to test
different way okay so if I want to test I can run npm this by looking at it I
I can run npm this by looking at it I will say npm startop okay so if I hit
will say npm startop okay so if I hit npm staff you guys can see uh it will
npm staff you guys can see uh it will take a little bit time for the first
take a little bit time for the first time and it is uh not like the njs
time and it is uh not like the njs application uh sorry the express JS
application uh sorry the express JS application that we created it will show
application that we created it will show some logs okay it we say okay our
some logs okay it we say okay our application is running on localport 3000
application is running on localport 3000 and API we'll just simply go there and
and API we'll just simply go there and see what's going on so the API endpoint
see what's going on so the API endpoint is given for us you can just simply copy
is given for us you can just simply copy or we and just uh copy uh copy this
or we and just uh copy uh copy this and uh paste it in our application and
and uh paste it in our application and what you guys get a simple me uh message
what you guys get a simple me uh message saying hello API okay so we will get a
saying hello API okay so we will get a simple message a simple
simple message a simple Json uh the key is message and the value
Json uh the key is message and the value is hello AP okay so we get a
is hello AP okay so we get a simple Json response when we go to Local
simple Json response when we go to Local Host port 3,000 and API inome okay
Host port 3,000 and API inome okay so you you you guys might think okay
so you you you guys might think okay there is app. get like what we have seen
there is app. get like what we have seen in the previous example there will be
in the previous example there will be something
like something similar there right yes but it bit little bit of different is
but it bit little bit of different is that we
that we have in this uh in this framework in
have in this uh in this framework in this m this framework we have introduced
this m this framework we have introduced what we called tier architecture we will
what we called tier architecture we will see the ti
see the ti architecture anything with this project
architecture anything with this project setup I know the there are lot of files
setup I know the there are lot of files in here with kep config what are these
in here with kep config what are these don't do not want to worry about these
don't do not want to worry about these files in in in this stage all you just
files in in in this stage all you just need to know okay the package is there
need to know okay the package is there and the SRC directory is here at least
and the SRC directory is here at least SRC and familiar one is not modules as I
SRC and familiar one is not modules as I mentioned earlier this contain all the
mentioned earlier this contain all the runtime libraries and other things just
runtime libraries and other things just for now just ignore any questions up
for now just ignore any questions up until this okay at least you guys need
until this okay at least you guys need to create a project and you need to
to create a project and you need to start okay so you know where to get the
start okay so you know where to get the script you can say npm start and the
script you can say npm start and the application will start okay and there is
application will start okay and there is another command that you can run if you
another command that you can run if you look at the project Jon so Project G
look at the project Jon so Project G sorry not the project Jon package Json
sorry not the project Jon package Json file the start command is also can be
file the start command is also can be achieved by index Ser okay you can say
achieved by index Ser okay you can say two things you can say npm start or you
two things you can say npm start or you can say NX
can say NX server the both will do the same thing
server the both will do the same thing it will start the application okay any
it will start the application okay any questions up until this because we will
questions up until this because we will be into the enti architecture
okay awesome if you guys have anything just interrupt me anytime
just interrupt me anytime okay all right let's go back to the
okay all right let's go back to the source code
source code itself as we uh discuss we will be
itself as we uh discuss we will be starting from the SRC directory and we
starting from the SRC directory and we looked at the main just simply look at
looked at the main just simply look at it as
it as uh it's starting the web server on Port
uh it's starting the web server on Port 3000 and it's starting the boot strap
3000 and it's starting the boot strap okay
okay and one thing that we need to look is in
and one thing that we need to look is in here something
here something called uh app module okay there is a uh
called uh app module okay there is a uh there is when you are looking at this
there is when you are looking at this file it is creating or it is using
file it is creating or it is using something called app module this is what
something called app module this is what this is not something that you find in
this is not something that you find in the nests application we we have but
the nests application we we have but simply uh in here what we have done is
simply uh in here what we have done is uh as I mentioned earlier we will be
uh as I mentioned earlier we will be splitting up our application we'll be
splitting up our application we'll be separating these things in different
separating these things in different forms so module is modularization is
forms so module is modularization is something that we will consider so a
something that we will consider so a module think a module
as as a single uh single uh feature within our application
single uh feature within our application for
for example we we talked about uh several
example we we talked about uh several things in our system we talked about
things in our system we talked about users we talked about schools and we
users we talked about schools and we talked about um teachers okay so within
talked about um teachers okay so within our system we will have three uh three
our system we will have three uh three features user
features user School user school and teachers so we
School user school and teachers so we have three different features within our
have three different features within our application so we can we can categorize
application so we can we can categorize or we can uh have things related to
or we can uh have things related to users within the user module okay
users within the user module okay something related to user we will have
something related to user we will have within the user module something related
within the user module something related to
to um something related to the school we
um something related to the school we can have a school modu if something
can have a school modu if something related to teacher we can have a teacher
related to teacher we can have a teacher module so think of the
module so think of the um think all the DS and everything
um think all the DS and everything linking to one another linking to
linking to one another linking to another as in a single entry point or
another as in a single entry point or single packaging point or single feature
single packaging point or single feature point we can call it as a module okay so
point we can call it as a module okay so the app module is a special module in in
the app module is a special module in in this framework okay the app module is
this framework okay the app module is where we have
where we have uh all the modules report this is like
uh all the modules report this is like the starting point for our application
the starting point for our application okay so we have a starting point for
okay so we have a starting point for application so the uh app module uh have
application so the uh app module uh have uh few things you guys can see these an
uh few things you guys can see these an what we call these decorations do not
what we call these decorations do not worry about these things right now so we
worry about these things right now so we have things like controllers so if you
have things like controllers so if you guys can remember we have three tiers
guys can remember we have three tiers within our application the first one is
within our application the first one is the uh end point or the controller layer
the uh end point or the controller layer what we call so we can have all the
what we call so we can have all the controllers defined in a controller
controllers defined in a controller layer okay and we can have the business
layer okay and we can have the business Logics we discuss business logic we call
Logics we discuss business logic we call in this framework we call these things
in this framework we call these things providers okay do not expect uh all the
providers okay do not expect uh all the Frameworks in the world we'll call these
Frameworks in the world we'll call these things as uh control
things as uh control or endpoint uh business Logics or data
or endpoint uh business Logics or data layers okay each Frameworks has its own
layers okay each Frameworks has its own definition okay so in NJ the um the
definition okay so in NJ the um the controller layer is basically controlers
controller layer is basically controlers but the business logic layer what we
but the business logic layer what we call is something called uh we in in
call is something called uh we in in here we call like providers or Services
here we call like providers or Services okay and in the data layer in a data
okay and in the data layer in a data layer we do not call that as a data
layer we do not call that as a data layer but we call it as a repository
layer but we call it as a repository okay so different things have different
okay so different things have different namings but the architecture the three
namings but the architecture the three tis will remain most of the time the
tis will remain most of the time the same okay so within the app module you
same okay so within the app module you will find controllers and services okay
will find controllers and services okay the providers and controllers so these
the providers and controllers so these are the controllers that we saw if I go
are the controllers that we saw if I go to the app. controller file you will see
to the app. controller file you will see the
the um controller as you guys can
um controller as you guys can remember you guys can see the to API
remember you guys can see the to API nothing no end points are available
nothing no end points are available there so it's going to be responding for
there so it's going to be responding for this okay and the data that we are
this okay and the data that we are getting is coming from the app service
getting is coming from the app service okay and you guys can see the thing that
okay and you guys can see the thing that we have seen in here that is called the
we have seen in here that is called the hello APM okay that is what we are
hello APM okay that is what we are getting here so we will forget about all
getting here so we will forget about all these things just want to show you guys
these things just want to show you guys how it works and we will create a module
how it works and we will create a module from scratch okay we'll create a module
from scratch okay we'll create a module from scratch we will Define the uh
from scratch we will Define the uh controller layer we will Define the
controller layer we will Define the service layer and uh probably a dummy
service layer and uh probably a dummy repository layer okay because we do not
repository layer okay because we do not have the database everything set up
have the database everything set up right now right now we will create uh a
right now right now we will create uh a simple module and we will incorporate
simple module and we will incorporate into our application okay we'll see how
into our application okay we'll see how we can create multiple modules and
we can create multiple modules and incorporate okay so basically
Click on any text or timestamp to jump to that moment in the video
Share:
Most transcripts ready in under 5 seconds
One-Click Copy125+ LanguagesSearch ContentJump to Timestamps
Paste YouTube URL
Enter any YouTube video link to get the full transcript
Transcript Extraction Form
Most transcripts ready in under 5 seconds
Get Our Chrome Extension
Get transcripts instantly without leaving YouTube. Install our Chrome extension for one-click access to any video's transcript directly on the watch page.
Works with YouTube, Coursera, Udemy and more educational platforms
Get Instant Transcripts: Just Edit the Domain in Your Address Bar!
YouTube
←
→
↻
https://www.youtube.com/watch?v=UF8uR6Z6KLc
YoutubeToText
←
→
↻
https://youtubetotext.net/watch?v=UF8uR6Z6KLc