# netconnect-io

> A custom real-time communication library using HTTP server.

Latest version **1.0.1** (published 2023-04-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install netconnect-io
pnpm add netconnect-io
yarn add netconnect-io
bun add netconnect-io
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-04-11 |
| First published | 2023-04-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | arashamini |
| Keywords | netConnect-io, real-time, communication, http server |

## Links

- npm: https://www.npmjs.com/package/netconnect-io
- Repository: https://github.com/ghalbeyou/netconnect-io
- Homepage: https://github.com/ghalbeyou/netconnect-io#readme
- Issues: https://github.com/ghalbeyou/netconnect-io/issues
- npm.io page: https://npm.io/package/netconnect-io

## Recent versions

- 1.0.1 (latest) — 2023-04-11
- 1.0.0 — 2023-04-11

## README

# `netConnect.io` Module

`netConnect.io` is a powerful Node.js module that provides a simple and efficient way to handle incoming HTTP requests and register event listeners. With `netConnect.io`, you can easily build scalable and robust server-side applications that communicate over HTTP.
## Installion
To install this package and use it, you need to first install `http` module:
```bash
$ npm install http
```
then, you need to install netConnect.io package:
```bash
$ npm install netconnect-io
```
## Usage

### For Server

```javascript
const netConnectIO = require('netconnect-io');

// Create an HTTP server
const server = http.createServer();

// Create an instance of netConnectIO with the server
const netConnectIO = new netConnectIO(server);

// Register an event listener
netConnectIO.on('event', (message, { request, response }) => {
  // Handle the event here
});

// Start the server
server.listen(3000, () => {
  console.log('Server is listening on port 3000');
});
```
### For Client
```javascript
const http = require('http');

const data = JSON.stringify({
  event: 'eventName',
  message: 'Hello from client!',
});

const options = {
  hostname: 'localhost',
  port: 3000,
  path: '/',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
  },
};

const req = http.request(options, (res) => {
  console.log(`Response status code: ${res.statusCode}`);
  console.log(`Response headers: ${JSON.stringify(res.headers)}`);

  res.on('data', (chunk) => {
    console.log(`Response body: ${chunk.toString()}`);
  });
});

req.on('error', (error) => {
  console.error(`Request error: ${error.message}`);
});

req.write(data);
req.end();
```
## API

The api can be find in [`API.MD`](API.md) file.

---
_Source: https://npm.io/package/netconnect-io · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
