Introduction to Express
#Introduction to Express
* What is a framework? how is it different from a library?
Frameworks are code that someone else wrote usually a lot of people wrote because it's a lot more code that we can use inside of our application.
Both library and framework are external code that you're including in your won applicaiton, but library is something that you're in control of,
if you want to use a library, you can use one method, ten method , it's up to us which parts of it we use. we might only use a few of the method s for
animations or we might use 100 different methods.
With a framework on the other hand, we give up a little bit of control where if we use a framework like the one we're going to use which is Express
we have some decisions that have been made for us that we have to abide by in order to use the framework.
* Whar is Express?
framework of web development
flask for python, Django for Python, rails for Ruby,Sinatra for Ruby
* Why are we using Express?
most popular
very light wight framework
unopinionated means flexible
#Our First Express APP
*Review an exisiting app(DogDemo)
*Review Http response/requese lifecycle
*create our own simple Express APP
#NPM Init and package
.json*Use the '--save'flag to install package
it will take the package name and version in automatically save it into our package.json
*Explain what the package.json file does
this file holds metadata relevant to the project
*use 'npm init'to create a new package.json
#More Routing !
*show the '*'route matcher
when we use the star instead of a route definitiaon, it will match anything that comes in at all
*Write routes containing route paramters
define an pattern in a route
app.get("/r/:subredditName/comments/:id/:title");
*Discuss route order
if we put the star up top, no other routes will run below it