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

cloudflare-tcp-fetcher

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudflare-tcp-fetcher - npm Package Compare versions

Comparing version 0.9.1 to 0.9.2

10

example/src/index.ts

@@ -1,7 +0,13 @@

import { fetchUsingTcp } from "cloudflare-tcp-fetcher";
import { fetchUsingTcp } from "../../src/index";
export default {
async fetch(request: Request, env: never, ctx: ExecutionContext): Promise<Response> {
return fetchUsingTcp("https://google.com");
const response = await fetchUsingTcp("https://httpbin.org/delete", {
method: "DELETE"
});
return Response.json({
body: await response.json()
});
},
};

2

package.json
{
"name": "cloudflare-tcp-fetcher",
"version": "0.9.1",
"version": "0.9.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -12,5 +12,22 @@ # cloudflare-tcp-fetcher

### Using the fetchUsingTcp function
You can also input the TcpFetcher in the `init` object to reuse a connection.
```ts
import { fetchUsingTcp } from "cloudflare-tcp-fetcher";
export default {
async fetch(request: Request, env: never, ctx: ExecutionContext): Promise<Response> {
return fetchUsingTcp("https://google.com", {
method: "GET"
});
}
}
```
### Using the TcpFetcher class
You can re-use the TcpFetcher class until the worker is closed.
> Note: you can not use the `TcpFetcher` instance with `fetch` because the worker will complain that `TcpFetcher` is not an instance of `Fetcher` :/
```ts

@@ -20,3 +37,3 @@ import { TcpFetcher } from "cloudflare-tcp-fetcher";

export default {
async fetch(request: Request, env: never, ctx: ExecutionContext): Promise<Response> {
async fetch(request: Request, env: never, ctx: ExecutionContext): Promise<Response> {
const fetcher = new TcpFetcher();

@@ -30,16 +47,1 @@

```
### Using the fetchUsingTcp function
You can also input the TcpFetcher in the `init` object to reuse a connection.
```ts
import { fetchUsingTcp } from "cloudflare-tcp-fetcher";
export default {
async fetch(request: Request, env: never, ctx: ExecutionContext): Promise<Response> {
return fetchUsingTcp("https://google.com", {
method: "GET"
});
}
}
```

@@ -33,3 +33,3 @@ import { connect } from 'cloudflare:sockets';

write(`GET ${url.pathname}${url.search}${url.hash} HTTP/1.1\r\n`);
write(`${request.method} ${url.pathname}${url.search}${url.hash} HTTP/1.1\r\n`);
write(`Host: ${url.host}\r\n`);

@@ -36,0 +36,0 @@

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