@travetto/net
Advanced tools
Comparing version 1.0.0-rc.9 to 1.0.0
@@ -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); | ||
}); | ||
``` | ||
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
12440
8
257
0
1
17
Updated@travetto/base@^1.0.0