update tsconfig

This commit is contained in:
Philipp Kunz 2024-04-14 18:02:08 +02:00
parent 554a7d9647
commit e5111f0433
4 changed files with 164 additions and 51 deletions

View File

@ -9,12 +9,24 @@
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartnetwork",
"description": "network diagnostics",
"description": "A toolkit for network diagnostics including speed tests, port availability checks, and more.",
"npmPackagename": "@push.rocks/smartnetwork",
"license": "MIT"
"license": "MIT",
"keywords": [
"network diagnostics",
"ping",
"port check",
"speed test",
"network interface",
"public IP retrieval",
"Cloudflare speed test",
"network performance",
"network utility",
"TypeScript"
]
}
},
"tsdocs": {
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

View File

@ -2,7 +2,7 @@
"name": "@push.rocks/smartnetwork",
"version": "3.0.2",
"private": false,
"description": "network diagnostics",
"description": "A toolkit for network diagnostics including speed tests, port availability checks, and more.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
@ -43,5 +43,17 @@
],
"browserslist": [
"last 1 chrome versions"
],
"keywords": [
"network diagnostics",
"ping",
"port check",
"speed test",
"network interface",
"public IP retrieval",
"Cloudflare speed test",
"network performance",
"network utility",
"TypeScript"
]
}

1
readme.hints.md Normal file
View File

@ -0,0 +1 @@

182
readme.md
View File

@ -1,61 +1,149 @@
# @pushrocks/smartnetwork
# @push.rocks/smartnetwork
network diagnostics
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartnetwork)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartnetwork)
* [github.com (source mirror)](https://github.com/pushrocks/smartnetwork)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartnetwork/)
## Install
## Status for master
To install `@push.rocks/smartnetwork`, run the following command in your terminal:
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartnetwork/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartnetwork/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartnetwork)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartnetwork)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartnetwork)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartnetwork)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartnetwork)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
```bash
npm install @push.rocks/smartnetwork --save
```
This command will download `@push.rocks/smartnetwork` and add it to your project's `package.json` file.
## Usage
In this section, we will dive deep into the capabilities of the `@push.rocks/smartnetwork` package, exploring its various features through TypeScript examples. The package is designed to simplify network diagnostics tasks, including speed tests, port availability checks, ping operations, and more.
### Basic Setup
First, import the package into your project:
```typescript
import * as smartnetwork from 'smartnetwork';
const testSmartNetwork = new smartnetwork.SmartNetwork();
const run = async () => {
// measure average speed over a period of 5 seconds
// the structure of speedResult is self explanatory using TypeScript (or the linked TypeDoc above)
const speedResult: smartnetwork.SpeedResult = testSmartNetwork.getSpeed(5000);
// you can check for local ports before trying to bind to it from your nodejs program
const isLocalPortUnused: boolean = await testSmartNetwork.isLocalPortUnused(1234);
// you can run basic port checks on remote domains.
const isRemotePortAvailable: boolean = await testSmartNetwork.isRemotePortAvailable(
'google.com:80'
);
// just another way to call for the same thing as above
const isRemotePortAvailable: boolean = await testSmartNetwork.isRemotePortAvailable(
'google.com',
80
);
};
import { SmartNetwork } from '@push.rocks/smartnetwork';
```
## Contribution
Then, create an instance of `SmartNetwork`:
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
```typescript
const myNetwork = new SmartNetwork();
```
For further information read the linked docs at the top of this readme.
### Performing a Speed Test
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
You can measure the network speed using the `getSpeed` method. This feature leverages Cloudflare's speed test capabilities to assess your internet connection's download and upload speeds.
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
```typescript
const speedTest = async () => {
const speedResult = await myNetwork.getSpeed();
console.log(`Download speed: ${speedResult.downloadSpeed} Mbps`);
console.log(`Upload speed: ${speedResult.uploadSpeed} Mbps`);
console.log(`Latency: ${speedResult.averageTime} ms`);
};
speedTest();
```
### Checking Port Availability Locally
The `isLocalPortUnused` method allows you to check if a specific port on your local machine is available for use.
```typescript
const checkLocalPort = async (port: number) => {
const isUnused = await myNetwork.isLocalPortUnused(port);
if (isUnused) {
console.log(`Port ${port} is available.`);
} else {
console.log(`Port ${port} is in use.`);
}
};
checkLocalPort(8080); // Example port number
```
### Checking Remote Port Availability
To verify if a certain port is available on a remote server, use `isRemotePortAvailable`. This can help determine if a service is up and reachable.
```typescript
const checkRemotePort = async (hostname: string, port: number) => {
const isAvailable = await myNetwork.isRemotePortAvailable(hostname, port);
if (isAvailable) {
console.log(`Port ${port} on ${hostname} is available.`);
} else {
console.log(`Port ${port} on ${hostname} is not available.`);
}
};
checkRemotePort('example.com', 443); // Checking HTTPS port on example.com
```
### Using Ping
The `ping` method allows you to send ICMP packets to a host to measure round-trip time and determine if the host is reachable.
```typescript
const pingHost = async (hostname: string) => {
const pingResult = await myNetwork.ping(hostname);
if (pingResult.alive) {
console.log(`${hostname} is reachable. RTT: ${pingResult.time} ms`);
} else {
console.log(`${hostname} is not reachable.`);
}
};
pingHost('google.com');
```
### Getting Network Gateways
You can also retrieve information about your network gateways, including the default gateway used by your machine.
```typescript
const showGateways = async () => {
const gateways = await myNetwork.getGateways();
console.log(gateways);
const defaultGateway = await myNetwork.getDefaultGateway();
console.log(`Default Gateway: `, defaultGateway);
};
showGateways();
```
### Discovering Public IP Addresses
To find out your public IPv4 and IPv6 addresses, the following method can be used:
```typescript
const showPublicIps = async () => {
const publicIps = await myNetwork.getPublicIps();
console.log(`Public IPv4: ${publicIps.v4}`);
console.log(`Public IPv6: ${publicIps.v6}`);
};
showPublicIps();
```
The `@push.rocks/smartnetwork` package provides an easy-to-use, comprehensive suite of tools for network diagnostics and monitoring, encapsulating complex network operations into simple asynchronous methods. By leveraging TypeScript, developers can benefit from type checking, ensuring that they can work with clear structures and expectations.
These examples offer a glimpse into the module's utility in real-world scenarios, demonstrating its versatility in handling common network tasks. Whether you're developing a network-sensitive application, diagnosing connectivity issues, or simply curious about your network performance, `@push.rocks/smartnetwork` equips you with the tools you need.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.