New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@orpc/server-standard-fetch

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orpc/server-standard-fetch - npm Package Compare versions

Comparing version 0.0.0-next.60b3782 to 0.0.0-next.63309dc

dist/src/body.d.ts

124

dist/index.js

@@ -1,6 +0,124 @@

// src/index.ts
var author = "unnoq";
// src/body.ts
import { contentDisposition, parseContentDisposition } from "@orpc/server-standard";
async function toStandardBody(re) {
if (!re.body) {
return void 0;
}
const contentDisposition2 = re.headers.get("content-disposition");
if (contentDisposition2) {
const fileName = parseContentDisposition(contentDisposition2).parameters.filename;
if (typeof fileName === "string") {
const blob2 = await re.blob();
return new File([blob2], fileName, {
type: blob2.type
});
}
}
const contentType = re.headers.get("content-type");
if (!contentType || contentType.startsWith("application/json")) {
const text = await re.text();
if (!text) {
return void 0;
}
return JSON.parse(text);
}
if (contentType.startsWith("multipart/form-data")) {
return await re.formData();
}
if (contentType.startsWith("application/x-www-form-urlencoded")) {
return new URLSearchParams(await re.text());
}
if (contentType.startsWith("text/")) {
return await re.text();
}
const blob = await re.blob();
return new File([blob], "blob", {
type: blob.type
});
}
function toFetchBody(body, headers) {
headers.delete("content-type");
headers.delete("content-disposition");
if (body === void 0) {
return void 0;
}
if (body instanceof Blob) {
headers.set("content-type", body.type);
headers.set("content-length", body.size.toString());
headers.set(
"content-disposition",
contentDisposition(body instanceof File ? body.name : "blob", { type: "inline" })
);
return body;
}
if (body instanceof FormData) {
return body;
}
if (body instanceof URLSearchParams) {
return body;
}
headers.set("content-type", "application/json");
return JSON.stringify(body);
}
// src/headers.ts
function toStandardHeaders(headers, standardHeaders = {}) {
for (const [key, value] of headers) {
if (Array.isArray(standardHeaders[key])) {
standardHeaders[key].push(value);
} else if (standardHeaders[key] !== void 0) {
standardHeaders[key] = [standardHeaders[key], value];
} else {
standardHeaders[key] = value;
}
}
return standardHeaders;
}
function toFetchHeaders(headers, fetchHeaders = new Headers()) {
for (const [key, value] of Object.entries(headers)) {
if (Array.isArray(value)) {
for (const v of value) {
fetchHeaders.append(key, v);
}
} else if (value !== void 0) {
fetchHeaders.append(key, value);
}
}
return fetchHeaders;
}
// src/request.ts
import { once } from "@orpc/server-standard";
function toStandardRequest(request) {
return {
raw: { request },
url: new URL(request.url),
signal: request.signal,
method: request.method,
body: once(() => toStandardBody(request)),
get headers() {
const headers = toStandardHeaders(request.headers);
Object.defineProperty(this, "headers", { value: headers, writable: true });
return headers;
},
set headers(value) {
Object.defineProperty(this, "headers", { value, writable: true });
}
};
}
// src/response.ts
function toFetchResponse(response) {
const headers = toFetchHeaders(response.headers);
const body = toFetchBody(response.body, headers);
return new Response(body, { headers, status: response.status });
}
export {
author
toFetchBody,
toFetchHeaders,
toFetchResponse,
toStandardBody,
toStandardHeaders,
toStandardRequest
};
//# sourceMappingURL=index.js.map

6

dist/src/index.d.ts

@@ -1,3 +0,5 @@

/** unnoq */
export declare const author = "unnoq";
export * from './body';
export * from './headers';
export * from './request';
export * from './response';
//# sourceMappingURL=index.d.ts.map
{
"name": "@orpc/server-standard-fetch",
"type": "module",
"version": "0.0.0-next.60b3782",
"version": "0.0.0-next.63309dc",
"license": "MIT",

@@ -30,2 +30,5 @@ "homepage": "https://unnoq.com",

],
"dependencies": {
"@orpc/server-standard": "0.0.0-next.63309dc"
},
"scripts": {

@@ -32,0 +35,0 @@ "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",

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