serve-handler
Advanced tools
Comparing version 3.4.0 to 3.5.0
{ | ||
"name": "serve-handler", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"description": "The routing foundation of `serve` and static deployments on Now", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -259,3 +259,3 @@ # serve-handler | ||
If you want to replace the methods the package is using for interacting with the file system, you can pass them as the fourth argument to the function call. | ||
If you want to replace the methods the package is using for interacting with the file system and sending responses, you can pass them as the fourth argument to the function call. | ||
@@ -268,3 +268,4 @@ These are the methods used by the package (they can all return a `Promise` or be asynchronous): | ||
createReadStream(path) {}, | ||
readdir(path) {} | ||
readdir(path) {}, | ||
sendError(absolutePath, response, acceptsJSON, root, handlers, config, error) {} | ||
}); | ||
@@ -271,0 +272,0 @@ ``` |
@@ -20,8 +20,2 @@ // Native | ||
const getHandlers = methods => Object.assign({ | ||
stat: promisify(stat), | ||
createReadStream: createReadStream, | ||
readdir: promisify(readdir) | ||
}, methods); | ||
const sourceMatches = (source, requestPath, allowSegments) => { | ||
@@ -497,2 +491,9 @@ const keys = []; | ||
const getHandlers = methods => Object.assign({ | ||
stat: promisify(stat), | ||
createReadStream, | ||
readdir: promisify(readdir), | ||
sendError | ||
}, methods); | ||
module.exports = async (request, response, config = {}, methods = {}) => { | ||
@@ -633,3 +634,4 @@ const cwd = process.cwd(); | ||
if (!stats) { | ||
return sendError(absolutePath, response, acceptsJSON, current, handlers, config, { | ||
// allow for custom 404 handling | ||
return handlers.sendError(absolutePath, response, acceptsJSON, current, handlers, config, { | ||
statusCode: 404, | ||
@@ -636,0 +638,0 @@ code: 'not_found', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38899
554
289