express static Flashcards
What does express.static() return?
This is a built-in middleware function in Express. It serves static files. The root argument specifies the root directory from which to serve static assets. The function determines the file to serve by combining req.url with the provided root directory. When a file is not found, instead of sending a 404 response, it instead calls next() to move on to the next middleware, allowing for stacking and fall-backs. It returns a middleware function
What is the local __dirname variable in a Node.js module?
The directory name of the current module. The absolute path to the current module.
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. Zero-length path segments are ignored. If the joined path string is a zero-length string then ‘.’ will be returned, representing the current working directory.