Socket
Socket
Sign inDemoInstall

edge-runtime

Package Overview
Dependencies
Maintainers
1
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edge-runtime - npm Package Compare versions

Comparing version 1.1.0-beta.35 to 1.1.0-beta.36

59

dist/server/create-handler.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc