Node/express Flashcards
Routing refers to…
… determining how an application responds to a client request to a particular endpoint.
What’s an endpoint?
A URI (or path) and a specific HTTP request method (GET, POST, and so on).
What’s a route? (Express)
A combination of path and http verb.
How is a route definition structured in express?
app.METHOD(PATH, HANDLER)
METHOD = http verb in lowercase
PATH = uri/ path on server
HANDLER = function to execute when route (path + method) is matched
What four verbs are possible in routes in express?
Get, post, put, delete
What are the two parameters of the handler function in an express route?
Request and response:
(req, res) => {
res.send(“response “)
}
What is the method for using middleware in express?
app.use( )
What’s the default path for app.use?
“/“ (meaning the root)
How to serve static files in express?
app.use(express.static(‘public ’)
“Public” represents the root directory of where your static files are.