@hattip/compose
Advanced tools
Comparing version 0.0.16 to 0.0.17
@@ -8,11 +8,2 @@ // src/index.ts | ||
const flatHandlers = handlers.flat().filter(Boolean); | ||
flatHandlers.unshift((context) => { | ||
context.url = new URL(context.request.url); | ||
context.method = context.request.method; | ||
context.locals = {}; | ||
context.handleError = (error) => { | ||
console.error(error); | ||
return new Response("Internal Server Error", { status: 500 }); | ||
}; | ||
}); | ||
return flatHandlers.map(wrap).reduceRight((prev, current) => { | ||
@@ -27,3 +18,15 @@ return async (context) => { | ||
function compose(...handlers) { | ||
return composePartial([...handlers, finalHandler]); | ||
return composePartial([ | ||
(context) => { | ||
context.url = new URL(context.request.url); | ||
context.method = context.request.method; | ||
context.locals = {}; | ||
context.handleError = (error) => { | ||
console.error(error); | ||
return new Response("Internal Server Error", { status: 500 }); | ||
}; | ||
}, | ||
...handlers, | ||
finalHandler | ||
]); | ||
} | ||
@@ -30,0 +33,0 @@ function wrap(handler) { |
{ | ||
"name": "@hattip/compose", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"type": "module", | ||
@@ -12,3 +12,3 @@ "description": "Middleware system for HatTip", | ||
"dependencies": { | ||
"@hattip/core": "0.0.16" | ||
"@hattip/core": "0.0.17" | ||
}, | ||
@@ -15,0 +15,0 @@ "devDependencies": { |
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
8691
93
+ Added@hattip/core@0.0.17(transitive)
- Removed@hattip/core@0.0.16(transitive)
Updated@hattip/core@0.0.17