# rgwebhook

> An easy to use webhook link generate supporting multiple provider for hosting

Latest version **0.3.2** (published 2023-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install rgwebhook
pnpm add rgwebhook
yarn add rgwebhook
bun add rgwebhook
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2023-12-11 |
| First published | 2023-11-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 (+9 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ROBBING GAMER |
| Maintainers | wafiismail27 |
| Keywords | webhooklink, link, webhhook, ngrok, tunnelmole, @ngrok/ngrok, localtunnel, rg, robbing, gamer |

## Links

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

## Dependencies (5)

- [fastify](https://npm.io/package/fastify.md) ^4.24.3
- [tunnelmole](https://npm.io/package/tunnelmole.md) ^2.2.8
- [localtunnel](https://npm.io/package/localtunnel.md) ^2.0.2
- [@ngrok/ngrok](https://npm.io/package/@ngrok/ngrok.md) ^0.9.1
- [@fastify/sensible](https://npm.io/package/@fastify/sensible.md) ^5.5.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.3.2 (latest) — 2023-12-11
- 0.3.1 — 2023-12-11
- 0.3.0 — 2023-12-11
- 0.2.7 — 2023-12-04
- 0.2.6 — 2023-12-04
- 0.2.5 — 2023-12-04
- 0.2.4 — 2023-12-04
- 0.2.3 — 2023-12-04
- 0.2.2 — 2023-12-04
- 0.2.0 — 2023-12-04
- 0.1.2 — 2023-11-11
- 0.1.1 — 2023-11-11
- 0.1.0 — 2023-11-01

## README

# RgWebhook

## Overview

`RgWebhook` is a Node.js library designed to simplify the creation and management of webhooks using Express. It provides functionalities to create a local server for handling webhooks and exposes them via tunneling services like `ngrok`, `tunnelmole` or `localtunnel`.

## Installation

Install the `rgwebhook` package via npm:

```bash
npm install rgwebhook
```

## Usage

### Initializing the Webhook Server

```javascript
const { startServer, createWebhook } = require('rgwebhook');

// Start the server using ngrok
startServer({ provider: 'ngrok', port: 3000 })
  .then(() => {
    console.log('Server started!');
  })
  .catch((err) => {
    console.error('Error starting the server:', err);
  });
```

### Creating a Webhook

```javascript
try {
  const { webhookInstance, webhookUrl } = createWebhook('uniqueWebhookID', { additionalData: 'optional' });
  console.log('Webhook created with URL:', webhookUrl);

  // Use webhookInstance to listen for events
  webhookInstance.on('GET', (data) => {
    console.log('Received GET request data:', data);
  });
} catch (error) {
  console.error('Error creating the webhook:', error);
}
```

## API Reference

### `startServer(options)`

Starts the Express server and exposes it using the specified tunneling service.

- `options` (Object): Configuration options for starting the server.
  - `provider` (String): The tunneling service provider (`ngrok` or `tunnelmole` or `localtunnel`).
  - `port` (Number): The port on which the server will run.
  - `launchOptions` (Object, optional): Custom parameters to be passed to the respective provider on start.
  - `fastifyOptions` (Object, optional): Custom parameters to be passed to fastify on start.

Returns a Promise that resolves when the server is successfully started.

### `createWebhook(webhookId, data?)`

Creates a new webhook with a unique identifier and associated data.

- `webhookId` (String): A unique identifier for the webhook.
- `data` (Object, optional): Additional data associated with the webhook.

Returns an object containing the webhook instance (`EventEmitter`) and its URL.

## Notes

- Ensure the server is started before creating webhooks.
- Implement error handling to manage potential exceptions.
- Consider securing your webhooks with authentication mechanisms in production environments.

## Version

Current version: `0.3.0`

---

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