Router and Express Router Flashcards
HTTP Request/Response Cycle
- browser parses the URL, looking for the domain name
- browser sends query with the domain name to the ISP(internet service provider)
- The ISP looks up domain in DNS (domain name system) and matches it to an IP (internet protocol) address
- ISP sends IP address back to the browser-response-all items collected to be parsed by the browser
URL
Uniform resource locator Consists of: 1. protocol (http, https, ftp) 2. domain (mapped to IP address 3. port 4.path 5.query string
Web server role
parse URLs
Describe the architecture of a basic Express app. How is it organized?
-architecture that allows for middleware?
-framework made up of 4 pieces:
1. express()
2. application
3. request
4. response
5. router
architecture:
data- database and schema
services available to route
API layer and routes
Express
- minimalist framework
2. designed to allow anyone to contribute functionality
express()
- The top-level function exported by the Express module. – when called it:
1. creates an Express app
2. gives us access to the other Express objects (application, request, response, router)
(express) application
- object
- it is theExpress application itself
- provides methods to route HTTP requests
- provides methods to configure middleware
- provides other functionality relevant to constructing web applications
request
- Object that represents the HTTP request
- has properties to access the various features of the request such as query string, headers and so on.
- referred to as req
- passed to route handling methods
response
- Object that represents the HTTP response that is sent to the client when the request is completed.
- referred to as res
- passed to route handling methods.
- contains methods to format the response, set the response headers and status code.
router
- mini- application
2. used to make apps more modular
Tell me about a time when you’ve used Express Router. How was it helpful?
Express router:
a time I’ve used it- capstone!
super helpful in breaking up and organizing the different routes- much more manageable to work with the code
unit testing
testing individual components
NEED EXAMPLE
integration testing
how components behave when working with other components
uncover errors at the interface between components or communication between components
like testing the interactions of the router and the database and services
interface
refers to the shared boundary across which components exchange data
mocha
testing framework