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

@travetto/net

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/net - npm Package Compare versions

Comparing version 1.0.0-rc.9 to 1.0.0

README.js

7

package.json

@@ -7,4 +7,5 @@ {

"dependencies": {
"@travetto/base": "^1.0.0-rc.8"
"@travetto/base": "^1.0.0"
},
"title": "Network",
"description": "Network utilities of the travetto framework",

@@ -27,4 +28,4 @@ "homepage": "https://travetto.io",

},
"version": "1.0.0-rc.9",
"gitHead": "cbb74e652d4277ec98c98098b931d6503a586af2"
"version": "1.0.0",
"gitHead": "7579e30893669f4136472c7d0a327a9cfdd1c804"
}

@@ -1,22 +0,43 @@

travetto: Net
===
<!-- This file was generated by the framweork and should not be modified directly -->
<!-- Please modify https://github.com/travetto/travetto/tree/master/module/net/README.js and execute "npm run docs" to rebuild -->
# Network
## Network utilities of the travetto framework
**Install: primary**
**Install: @travetto/net**
```bash
$ npm install @travetto/net
npm install @travetto/net
```
Network utilities used by the framework.
## HTTP Requests
The http request functionality exists to allow for simple usage of the `node` [`http`](https://nodejs.org/api/http.html) and [`https`](https://nodejs.org/api/http.html) modules. This functionality exists, in lieu of alternatives, as a means to provide the smallest footprint possible. The logic itself is simple:
The http request functionality exists to allow for simple usage of the `node` [http](https://nodejs.org/api/http.html) and [https](https://nodejs.org/api/https.html) modules. [HttpRequest](https://github.com/travetto/travetto/tree/master/module/net/src/request.ts#L13) exists, in lieu of alternatives, as a means to provide the smallest footprint possible. Using it is fairly straightforward:
**Code: Structure of request commands**
**Code: Using HttpRequest**
```typescript
class HttpRequest {
static async exec(opts: ExecArgs, payload?: any): Promise<string>;
static async exec(opts: ExecArgs & { pipeTo: NodeJS.WritableStream }, payload?: any): Promise<http.IncomingMessage>;
static async exec(opts: ExecArgs & { pipeTo?: NodeJS.WritableStream }, payload?: any): Promise<string | http.IncomingMessage>;
static async execJSON<T, U = any>(opts: ExecArgs, payload?: U): Promise<T>;
import { HttpRequest } from '@travetto/net';
HttpRequest.exec({
url: 'https://gooogle.com',
}).then(res => {
console.log(res);
});
```
Or a more complex example:
**Code: Using HttpRequest to Make API Calls**
```typescript
import { HttpRequest } from '@travetto/net/src/request';
interface User {
id: number;
name: string;
}
```
HttpRequest.execJSON<User>({
url: 'https://localhost:3000/api',
method: 'post',
}, { id: 5, name: 'Test' }).then(res => {
console.log(res.name);
});
```
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