edge-runtime
Advanced tools
Comparing version 1.1.0-beta.35 to 1.1.0-beta.36
@@ -23,32 +23,39 @@ "use strict"; | ||
var _a, _b; | ||
const start = (0, time_span_1.default)(); | ||
const body = req.method !== 'GET' && req.method !== 'HEAD' | ||
? (0, body_streams_2.getClonableBodyStream)(req, options.runtime.evaluate('Uint8Array'), options.runtime.context.TransformStream) | ||
: undefined; | ||
const response = await options.runtime.dispatchFetch(String(getURL(req)), { | ||
headers: toRequestInitHeaders(req), | ||
method: req.method, | ||
body: body === null || body === void 0 ? void 0 : body.cloneBodyStream(), | ||
}); | ||
const waitUntil = response.waitUntil(); | ||
awaiting.add(waitUntil); | ||
waitUntil.finally(() => awaiting.delete(waitUntil)); | ||
res.statusCode = response.status; | ||
res.statusMessage = response.statusText; | ||
for (const [key, value] of Object.entries(toNodeHeaders(response.headers))) { | ||
if (value !== undefined) { | ||
res.setHeader(key, value); | ||
try { | ||
const start = (0, time_span_1.default)(); | ||
const body = req.method !== 'GET' && req.method !== 'HEAD' | ||
? (0, body_streams_2.getClonableBodyStream)(req, options.runtime.evaluate('Uint8Array'), options.runtime.context.TransformStream) | ||
: undefined; | ||
const response = await options.runtime.dispatchFetch(String(getURL(req)), { | ||
headers: toRequestInitHeaders(req), | ||
method: req.method, | ||
body: body === null || body === void 0 ? void 0 : body.cloneBodyStream(), | ||
}); | ||
const waitUntil = response.waitUntil(); | ||
awaiting.add(waitUntil); | ||
waitUntil.finally(() => awaiting.delete(waitUntil)); | ||
res.statusCode = response.status; | ||
res.statusMessage = response.statusText; | ||
for (const [key, value] of Object.entries(toNodeHeaders(response.headers))) { | ||
if (value !== undefined) { | ||
res.setHeader(key, value); | ||
} | ||
} | ||
if (response.body) { | ||
for await (const chunk of (0, body_streams_1.consumeUint8ArrayReadableStream)(response.body)) { | ||
res.write(chunk); | ||
} | ||
} | ||
const subject = `${req.socket.remoteAddress} ${req.method} ${req.url}`; | ||
const time = `${(_a = (0, pretty_ms_1.default)(start()) | ||
.match(/[a-zA-Z]+|[0-9]+/g)) === null || _a === void 0 ? void 0 : _a.join(' ')}`; | ||
const code = `${res.statusCode} ${http_status_1.default[res.statusCode]}`; | ||
(_b = options.logger) === null || _b === void 0 ? void 0 : _b.debug(`${subject} → ${code} in ${time}`); | ||
res.end(); | ||
} | ||
if (response.body) { | ||
for await (const chunk of (0, body_streams_1.consumeUint8ArrayReadableStream)(response.body)) { | ||
res.write(chunk); | ||
finally { | ||
if (!res.finished) { | ||
res.end(); | ||
} | ||
} | ||
const subject = `${req.socket.remoteAddress} ${req.method} ${req.url}`; | ||
const time = `${(_a = (0, pretty_ms_1.default)(start()) | ||
.match(/[a-zA-Z]+|[0-9]+/g)) === null || _a === void 0 ? void 0 : _a.join(' ')}`; | ||
const code = `${res.statusCode} ${http_status_1.default[res.statusCode]}`; | ||
(_b = options.logger) === null || _b === void 0 ? void 0 : _b.debug(`${subject} → ${code} in ${time}`); | ||
res.end(); | ||
}, | ||
@@ -55,0 +62,0 @@ waitUntil: () => Promise.all(awaiting), |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://edge-runtime.vercel.app/packages/runtime", | ||
"version": "1.1.0-beta.35", | ||
"version": "1.1.0-beta.36", | ||
"main": "dist/index.js", | ||
@@ -8,0 +8,0 @@ "bin": { |
Sorry, the diff of this file is not supported yet
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
87364
772