Express Flashcards
What is Express?
Express is a routing and middleware web framework for Node.js that has minimal functionality of its own: An Express application is essentially a series of middleware function calls.
How do you add express to your package dependencies?
npm install express
What Express application method binds the server to a network PORT?
app.listen([port[, host[, backlog]]][, callback])
How do you register a middleware with an Express application?
app.use([path,] callback [, callback…])
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
request object, response object, and the next middleware
What is the Content-Type header of HTTP requests and responses used for?
The Content-Type entity header is used to indicate the media type of the resource.
What does express.static() return?
Express.static() serves static files contained in the root directory
Syntax: express.static(root, [options])
What is the local __dirname variable in a Node.js module?
A string of the absolute path of the current module directory
What does the join() method of Node’s path module do?
The path.join() method joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.
Syntax: path.join([…paths])
Example: path.join('/foo', 'bar', 'baz/asdf', 'quux', '..'); // Returns: '/foo/bar/baz/asdf'