🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

cloudly-http

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudly-http - npm Package Compare versions

Comparing version

to
0.1.3

3

dist/Parser.d.ts

@@ -0,2 +1,3 @@

import type { Request as CloudflareRequest } from "@cloudflare/workers-types";
export declare function add(parser: (request: globalThis.Request | globalThis.Response) => Promise<any>, ...contentType: string[]): void;
export declare function parse(request: globalThis.Request | globalThis.Response): Promise<any>;
export declare function parse(request: globalThis.Request | CloudflareRequest | globalThis.Response): Promise<any>;
/// <reference lib="webworker.iterable" />
import type { Request as CloudflareRequest } from "@cloudflare/workers-types";
import { Method } from "../Method";

@@ -17,2 +18,3 @@ import { Header as RequestHeader } from "./Header";

readonly body?: any | Promise<any>;
readonly cloudflare?: Readonly<CloudflareRequest["cf"]>;
}

@@ -24,3 +26,3 @@ export declare namespace Request {

}>;
function from(request: globalThis.Request): Request;
function from(request: globalThis.Request | CloudflareRequest): Request;
function create(request: string | RequestLike): Request;

@@ -27,0 +29,0 @@ type Header = RequestHeader;

@@ -44,2 +44,3 @@ import { Method } from "../Method";

body: Parser.parse(request),
...("cf" in request && { cloudflare: request.cf }),
};

@@ -46,0 +47,0 @@ }

{
"name": "cloudly-http",
"version": "0.1.2",
"version": "0.1.3",
"description": "Improved handling of HTTP Requests and Responses.",

@@ -71,4 +71,5 @@ "author": "Simon Mika <simon@mika.se>",

"ts-jest": "^29.0.4",
"typescript": "^4.9.4"
"typescript": "^4.9.4",
"@cloudflare/workers-types": "^4.20230221.0"
}
}

@@ -0,3 +1,7 @@

import type { Request as CloudflareRequest } from "@cloudflare/workers-types"
const parsers: {
[contentType: string]: ((request: globalThis.Request | globalThis.Response) => Promise<any>) | undefined
[contentType: string]:
| ((request: globalThis.Request | CloudflareRequest | globalThis.Response) => Promise<any>)
| undefined
} = {}

@@ -10,3 +14,3 @@ export function add(

}
export function parse(request: globalThis.Request | globalThis.Response): Promise<any> {
export function parse(request: globalThis.Request | CloudflareRequest | globalThis.Response): Promise<any> {
const contentType = request.headers.get("Content-Type")

@@ -13,0 +17,0 @@ const type = contentType && contentType.split(";")

/// <reference lib="webworker.iterable" />
import type { Request as CloudflareRequest } from "@cloudflare/workers-types"
import { Method } from "../Method"

@@ -16,2 +17,3 @@ import * as Parser from "../Parser"

readonly body?: any | Promise<any>
readonly cloudflare?: Readonly<CloudflareRequest["cf"]>
}

@@ -56,3 +58,3 @@

}
export function from(request: globalThis.Request): Request {
export function from(request: globalThis.Request | CloudflareRequest): Request {
const url = new URL(request.url)

@@ -66,2 +68,3 @@ return {

body: Parser.parse(request),
...("cf" in request && { cloudflare: request.cf }),
}

@@ -68,0 +71,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet