Compare commits

...
9 Commits
Author SHA1 Message Date
allburov 5e2de1d47d [core] Bump to 2024.2.4
Release / amd64 - chrome - chrome (push) Waiting to run
Release / amd64 - chromium - latest (push) Waiting to run
Release / linux/arm64 - chromium - arm (push) Waiting to run
Release / amd64 - none - noweb (push) Waiting to run
Release / linux/arm64 - none - noweb-arm (push) Waiting to run
2024-02-25 17:57:29 +07:00
allburov 591ca51104 [core] add GET /health 2024-02-25 17:56:58 +07:00
allburov b210841158 [core] Fix documentation for message.revoked 2024-02-21 10:31:54 +07:00
allburov a223a3985b [core] Self-hosted solution 2024-02-19 14:52:23 +07:00
allburov 8baa6a73cd [core] Self-hosted 2024-02-19 14:52:07 +07:00
allburov 508efac2ea [core] Add links on index 2024-02-19 14:51:59 +07:00
allburov b6eed9e228 [core] Rewrite tiers 2024-02-19 14:46:17 +07:00
allburov b62cad07f0 [core] Icons on main page 2024-02-19 14:28:18 +07:00
allburov 6d552d27ac [core] Bold 2024-02-19 14:11:24 +07:00
24 changed files with 504 additions and 82 deletions

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
---
title : "WAHA"
description: "WAHA - WhatsApp HTTP API that you can run in a click!"
lead: "WAHA - WhatsApp HTTP API that you can run in a click!"
lead: "WAHA - <b>WhatsApp HTTP API</b> that you can run in a click!"
date: 2020-10-06T08:47:36+00:00
lastmod: 2020-10-06T08:47:36+00:00
draft: false
@@ -114,6 +114,14 @@ you'll get a webhook event with `hasMedia: True` field, but with no `media.url`.
}
```
### Health Check
<b>Health check is available in [WAHA Plus ![](/images/versions/plus.png)]({{< relref "/docs/how-to/plus-version" >}}) only.</b>
The following environment variables can be used to configure the [Health Check ->]({{< relref "/docs/how-to/other" >}}):
- `WHATSAPP_HEALTH_MEDIA_FILES_THRESHOLD_MB` - the threshold in MB for the media files storage. The default value is `100`.
- `WHATSAPP_HEALTH_SESSIONS_FILES_THRESHOLD_MB` - the threshold in MB for the sessions files storage. The default value is `100`.
- `WHATSAPP_HEALTH_MONGODB_TIMEOUT` - the timeout in milliseconds for the MongoDB health check. The default value is `5000`.
## Examples
#### Debug Mode
@@ -193,7 +193,8 @@ please [create an issue](https://github.com/devlikeapro/whatsapp-http-api/issues
| `GET /api/{session}/presence/{chatId}` | ➖ | ✔️ | ➖ |
| `POST /api/{session}/presence/{chatId}/subscribe` | ➖ | ✔️ | ➖ |
| **Other** | | | |
| `POST /api/version` | ➖ | ✔️ | ➖ |
| `GET /api/version` | ➖ | ✔️ | ➖ |
| `GET /health` ![](/images/versions/plus.png) | ✔️ | ✔️ | ✔️ |
| **Webhooks** | WEBJS | NOWEB | VENOM |
|-----------------------------------------------------|:-----:|:-----:|:-----:|
@@ -0,0 +1,192 @@
---
title: "Other"
description: "Other features and API"
lead: ""
date: 2020-10-06T08:48:45+00:00
lastmod: 2020-10-06T08:48:45+00:00
draft: false
images: [ ]
weight: 802
---
This page provides useful information about other features and API that are not covered in the other sections.
## Health Check
<b>Health check is available in [WAHA Plus ![](/images/versions/plus.png)]({{< relref "/docs/how-to/plus-version" >}}) only.</b>
The health check endpoint is used to determine the health of the service.
```
GET /health
```
It returns a **200 OK** status code if the service is healthy.
The response format:
```json
{
"status": "ok",
"info": {
"metric1": {
"field": "value"
},
"metric2": {
"field": "value"
}
},
"error": {},
"details": {}
}
```
Where:
- `status`: `'error' | 'ok' | 'shutting_down'` - If any health indicator failed the status will be `'error'`. If the app is shutting down but still accepting HTTP requests, the health check will have the `'shutting_down'` status.
- `info`: Object containing information of each health indicator which is of status `'up'`, or in other words "healthy".
- `error`: Object containing information of each health indicator which is of status `'down'`, or in other words "unhealthy".
- `details`: Object containing detailed information of each health indicator.
### Health Check Indicators
Few things we check in the health check:
- Media files storage space - `mediaFiles.space`
- Sessions files storage space - `sessionsFiles.space`
- MongoDB connection - `mongodb`
### Configuration
The following environment variables can be used to configure the health check:
- `WHATSAPP_HEALTH_MEDIA_FILES_THRESHOLD_MB` - the threshold in MB for the media files storage. The default value is `100`.
- `WHATSAPP_HEALTH_SESSIONS_FILES_THRESHOLD_MB` - the threshold in MB for the sessions files storage. The default value is `100`.
- `WHATSAPP_HEALTH_MONGODB_TIMEOUT` - the timeout in milliseconds for the MongoDB health check. The default value is `5000`.
### Examples
**Healthy response** when you use [Local Storage]({{< relref "/docs/how-to/storages#sessions" >}}) for session authentication:
**200 OK**
```json
{
"status": "ok",
"info": {
"mediaFiles.space": {
"status": "up",
"path": "/tmp/whatsapp-files",
"diskPath": "/",
"free": 132979355648,
"threshold": 104857600
},
"sessionsFiles.space": {
"status": "up",
"path": "/app/.sessions",
"diskPath": "/",
"free": 132979355648,
"threshold": 104857600
}
},
"error": {},
"details": {
"mediaFiles.space": {
"status": "up",
"path": "/tmp/whatsapp-files",
"diskPath": "/",
"free": 132979355648,
"threshold": 104857600
},
"sessionsFiles.space": {
"status": "up",
"path": "/app/.sessions",
"diskPath": "/",
"free": 132979355648,
"threshold": 104857600
}
}
}
```
**Healthy response** when you use [MongoDB Storage]({{< relref "/docs/how-to/storages#sessions" >}}) for session authentication:
**200 OK**
```json
{
"status": "ok",
"info": {
"mediaFiles.space": {
"status": "up",
"path": "/tmp/whatsapp-files",
"diskPath": "/",
"free": 132977496064,
"threshold": 104857600
},
"mongodb": {
"status": "up",
"message": "Up and running"
}
},
"error": {},
"details": {
"mediaFiles.space": {
"status": "up",
"path": "/tmp/whatsapp-files",
"diskPath": "/",
"free": 132977496064,
"threshold": 104857600
},
"mongodb": {
"status": "up",
"message": "Up and running"
}
}
}
```
**Unhealthy response example**
**503 Service Unavailable**
```json
{
"status": "error",
"info": {
"mediaFiles.space": {
"status": "up",
"path": "/tmp/whatsapp-files",
"diskPath": "/",
"free": 132976623616,
"threshold": 104857600
}
},
"error": {
"mongodb": {
"status": "down",
"error": "Timeout"
}
},
"details": {
"mediaFiles.space": {
"status": "up",
"path": "/tmp/whatsapp-files",
"diskPath": "/",
"free": 132976623616,
"threshold": 104857600
},
"mongodb": {
"status": "down",
"error": "Timeout"
}
}
}
```
## Get version
Returns the version of the installed docker image.
```
GET /api/version
```
```json
{
"version": "2024.2.3",
"engine": "NOWEB",
"tier": "PLUS",
"browser": "/usr/bin/google-chrome-stable"
}
```
@@ -49,17 +49,35 @@ Treat **WAHA Plus** it as an additional episode, behind-the-scenes videos, our n
We donate most of the donations down to the stream to the underlying libraries and tools - JS-community, Node, other libraries authors, personal contributors.
By donating to the **WAHA** you donate to the Open Source world!
### Features
### Tiers
The Plus additional features are:
The more you support the project - the more you get!
| | Core | Plus | Advanced | Pro |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------|---------|:--------:|:-------:|
| Messages limit | **∞** | **∞** | **∞** | **∞** |
| [Send and receive text messages ->]({{< relref "/docs/how-to/send-messages" >}}) | ✔️ | ✔️ | ✔️ | ✔️ |
| No license checks on installed instances | ✔️ | ✔️ | ✔️ | ✔️ |
| [Sessions limit ->]({{< relref "/docs/how-to/sessions" >}}) | **1** | **∞** | **∞** | **∞** |
| [Send and receive files ->]({{< relref "/docs/how-to/send-messages" >}}) | ➖️ | ✔️ | ✔️ | ✔️ |
| [Built-in Security ->]({{< relref "/docs/how-to/security" >}}) | ➖️ | ✔️ | ✔️ | ✔️ |
| [**Webhook retries** →]({{< relref "/docs/how-to/receive-messages#retries" >}}) | ➖️ | ✔️ | ✔️ | ✔️ |
| [MongoDB support ->]({{< relref "/docs/how-to/storages" >}}) | ➖️ | ✔️ | ✔️ | ✔️ |
| Access to **WAHA Plus** ![](/images/versions/plus.png) docker image with a personal key. | ➖️ | ✔️ | ✔️ | ✔️ |
| Special badge ([![patron:TIER](https://img.shields.io/badge/patron-TIER-188a42)](https://waha.devlike.pro/docs/how-to/plus-version/#tiers)) and labels (`patron:TIER`) on [project's issues, PRs and Discussion](https://github.com/devlikeapro/whatsapp-http-api) to highlight your support to the project! | | ✔️ | ✔️ | ✔️ |
| An invitation to **a private Github repository** so you have the **WAHA Plus** source code. | ➖️ | ➖️ | ✔️ | ✔️️ |
| Access to a Telegram group where we provide support and assistance. | ➖️ | ➖️ | ➖ | ✔️ |
| Access to an [experimental MOBILE engine]({{< relref "/docs/how-to/plus-version#tiers" >}})!. | ➖️ | ➖️ | ➖ | ✔️ |
| **Donation** | **FREE** | **$19** | **$39** | **$99** |
For **$19** donation you get:
1. **Secret password** for Docker Hub to download Plus image: `devlikeapro/whatsapp-http-api-plus`.
2. **All updates for one month** for the Plus image.
3. **NO LICENSE CHECKS** on installed instances!
4. **NO LICENSE EXPIRATION** on installed instances! We repeated it twice to make sure that you've got it 😊
{{< alert icon="💡" text="If you stay subscribed - the donation amount will never change for you and always be $19 to get monthly updates!" />}}
1. [**Send images\files\voices** →]({{< relref "/docs/how-to/send-messages" >}})
2. [**Receive images\files\voices** →]({{< relref "/docs/how-to/receive-messages" >}})
3. [**Webhook retries** →]({{< relref "/docs/how-to/receive-messages#retries" >}})
4. [**Security** →]({{< relref "/docs/how-to/security" >}})
5. [**Saving sessions** →]({{< relref "/docs/how-to/sessions" >}})
6. [**Support multiple sessions** →]({{< relref "/docs/how-to/sessions" >}})
7. **Priority in support** - on both bugs and features
### Why WAHA?
@@ -77,28 +95,6 @@ What is the difference between **WAHA Plus** and **other SaaS solutions** for Wh
## Get Plus ![](/images/versions/plus.png)
The more you support the project - the more you get!
### Tiers
Here's available tiers for our supporters:
| | Plus | Advanced | Pro |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|:--------:|:-------:|
| Access to WAHA Plus ![](/images/versions/plus.png) docker image with a personal key. | ✔️ | ✔️ | ✔️ |
| Special badge ([![patron:TIER](https://img.shields.io/badge/patron-TIER-188a42)](https://waha.devlike.pro/docs/how-to/plus-version/#tiers)) and labels (`patron:TIER`) on [project's issues, PRs and Discussion](https://github.com/devlikeapro/whatsapp-http-api) to highlight your support to the project! | ✔️ | ✔️ | ✔️ |
| An invitation to a private Github repository so you have the WAHA Plus source code. | ➖️ | ✔️ | ✔️️ |
| Access to a Telegram group where we provide support and assistance. | ➖️ | ➖ | ✔️ |
| Access to an [experimental MOBILE engine]({{< relref "/docs/how-to/plus-version#tiers" >}})!. | ➖️ | ➖ | ✔️ |
| **Donation** | **$19** | **$39** | **$99** |
For **$19** donation you get:
1. **Secret password** for Docker Hub to download Plus image: `devlikeapro/whatsapp-http-api-plus`.
2. **All updates for one month** for the Plus image.
3. **NO LICENSE CHECKS** on installed instances!
4. **NO LICENSE EXPIRATION** on installed instances! We repeated it twice to make sure that you've got it 😊
{{< alert icon="💡" text="If you stay subscribed - the donation amount will never change for you and always be $19 to get monthly updates!" />}}
### Patreon
<p align="center">
@@ -61,6 +61,8 @@ Under the hood, the WAHA stores the session data in the following directory stru
when you "logout" the session using [POST /api/sessions/logout]({{< relref "/docs/how-to/sessions#logout">}}) or providing `logout: True` in [POST /api/sessions/stop]({{< relref "/docs/how-to/sessions#stop">}})
it removes the directory with the session data.
### Health Check
The [WAHA Plus ![](/images/versions/plus.png)]({{< relref "/docs/how-to/plus-version" >}}) provides [the health check endpoint]({{< relref "/docs/how-to/other" >}}) that checks the local storage.
## Sessions - MongoDB
If you want to use the MongoDB to store the session data, you need to:
@@ -103,6 +105,9 @@ If you use the [MongoDB Atlas](https://www.mongodb.com/atlas/database) you must
For production please consider running the MongoDB server close to the WAHA server for the best performance and security reasons.
### Health Check
The [WAHA Plus ![](/images/versions/plus.png)]({{< relref "/docs/how-to/plus-version" >}}) provides [the health check endpoint]({{< relref "/docs/how-to/other" >}}) that checks the MongoDB connection.
## Media
When your WhatsApp instance receives media files, it stores them in the media storage.
@@ -136,6 +141,9 @@ Here's all the steps in one command:
docker run -v /path/to/on/host/.media:/app/.media -e WHATSAPP_FILES_FOLDER=/app/.media -e WHATSAPP_FILES_LIFETIME=0 -p 3000:3000/tcp devlikeapro/whatsapp-http-api-plus
```
### Health Check
The [WAHA Plus ![](/images/versions/plus.png)]({{< relref "/docs/how-to/plus-version" >}}) provides [the health check endpoint]({{< relref "/docs/how-to/other" >}}) that checks the local storage.
## Media - S3
If you're interested in using the S3 storage or any other cloud storage (like [self-hosted S3 - Minio](https://min.io/)),
please create an issue or vote for the S3 issue in [the GitHub repository](https://github.com/devlikeapro/whatsapp-http-api/issues?q=is%3Aissue+is%3Aopen+S3).
@@ -263,7 +263,7 @@ revokes a previously sent message.
```json
{
"event": "message.ack",
"event": "message.revoked",
"session": "default",
"payload": {
"before": {
@@ -23,6 +23,7 @@ You even can **subscribe to get new updates** there!
- Add support for [MongoDB as storage for Session data]({{< relref "/docs/how-to/storages" >}})
- Support persistent file storage for media files - [now you can save media files between container restarts]({{< relref "/docs/how-to/storages#media" >}})
- If you set `WHATSAPP_FILES_LIFETIME=0` environment variable - media files will be never deleted.
- Add `GET /api/health` endpoint to [check the health of the service](https://waha.devlike.pro/docs/how-to/other/)
## 2024.1
- Implement [Patron Portal](https://portal.devlike.pro/) where you can get your personal API key and manage your perks.
+71 -46
View File
@@ -1,79 +1,104 @@
{{ define "main" }}
<section class="section container-fluid mt-n3 pb-3">
<div class="row justify-content-center">
<div class="col-lg-12 text-center">
<h1 class="mt-0">{{ .Title }}</h1>
<section class='section container-fluid mt-n3 pb-3'>
<div class='row justify-content-center'>
<div class='col-lg-12 text-center'>
<h1 class='mt-0'>{{ .Title }}</h1>
</div>
<div class="col-lg-9 col-xl-9 text-center">
<div class="mb-4">
<img src="/images/logo.png" title="WhatsApp HTTP API" alt="logo" width="100"/>
<div class='col-lg-9 col-xl-9 text-center'>
<div class='mb-4'>
<img src='/images/logo.png' title='WhatsApp HTTP API' alt='logo' width='100' />
</div>
<p class="lead">{{ .Params.lead | safeHTML }}</p>
<p class='lead'>{{ .Params.lead | safeHTML }}</p>
<code>
docker run -it -p 3000:3000/tcp devlikeapro/whatsapp-http-api
</code>
<br/>
<br/>
<a class="btn btn-primary btn-lg px-4 mb-2"
href="/docs/{{ if .Site.Params.options.docsVersioning }}{{ .Site.Params.docsVersion }}/{{ end }}overview/introduction/"
role="button">Get Started</a>
<p class="meta"><a href="https://github.com/devlikeapro/whatsapp-http-api">Source code in GitHub.</a></p>
<br />
<br />
<a class='btn btn-primary btn-lg px-4 mb-2'
href='/docs/{{ if .Site.Params.options.docsVersioning }}{{ .Site.Params.docsVersion }}/{{ end }}overview/introduction/'
role='button'>Get Started</a>
<p class='meta'><a href='https://github.com/devlikeapro/whatsapp-http-api'>Source code in GitHub.</a></p>
</div>
</div>
</section>
{{ end }}
{{ define "sidebar-prefooter" }}
<section class="section section-sm">
<div class="container">
<div class="row justify-content-center text-center">
<div class="col-lg-5">
<h2 class="h4">It's free!</h2>
<section class='section section-sm'>
<div class='container'>
<div class='row justify-content-center text-center'>
<div class='col-lg-5'>
<img src='/images/icons/free.png' alt='Free' style='width: 5rem'>
<h2 class='h4'>It's free!</h2>
<p>
<b>WAHA Core</b> version is always free!
<a href='https://waha.devlike.pro/docs/how-to/plus-version/#tiers' target='_blank'>
<b>WAHA Core</b>
</a>
version is always free!
<br>
Even <b>WAHA Plus</b> version have no licence expiration!
Even
<a href='https://waha.devlike.pro/docs/how-to/plus-version/#tiers' target='_blank'>
<b>WAHA Plus</b>
</a>
version have no licence expiration!
</p>
</div>
<div class="col-lg-5">
<h2 class="h4">Language agnostic</h2>
<div class='col-lg-5'>
<img src='/images/icons/api.png' alt='API' style='width: 5rem'>
<h2 class='h4'>Language agnostic</h2>
<p>
Use your own favorite language - Python, JavaScript, PHP, C#, Clojure, or PowerShell.
<br/>
<small class="text-muted">
<br />
<small class='text-muted'>
PowerShell, really? Are you insane?! Choose another language, dude.
</small>
</p>
</div>
<div class="col-lg-5">
<h2 class="h4">Well documented</h2>
<p>Documentation has a lof examples and how-to guides.</p>
<div class='col-lg-5'>
<img src='/images/icons/document.png' alt='Document' style='width: 5rem'>
<h2 class='h4'>Well documented</h2>
<p>
<a href='https://waha.devlike.pro/docs/overview/introduction/' target='_blank'>
Documentation
</a>
has a lof examples and how-to guides.</p>
</div>
</div>
<div class="row justify-content-center text-center">
<div class="col-lg-5">
<h2 class="h4">Self hosted</h2>
<div class='row justify-content-center text-center'>
<div class='col-lg-5'>
<img src='/images/icons/servers.png' alt='Servers' style='width: 5rem'>
<h2 class='h4'>Self-hosted solution</h2>
<p>
No strings to suspicious SaaS WhatsApp HTTP API solutions. Install it on your own server!
<a href='https://waha.devlike.pro/docs/how-to/plus-version/#why-waha' target='_blank'>
No strings to suspicious SaaS WhatsApp HTTP API solutions.
</a>
Install it on your own server!
</p>
</div>
<div class="col-lg-5">
<h2 class="h4">Easy installation</h2>
<div class='col-lg-5'>
<img src='/images/icons/easy.png' alt='Easy' style='width: 5rem'>
<h2 class='h4'>Quick installation</h2>
<p>
You need to install <a href="https://docs.docker.com/engine/install/">Docker</a> and can run the API in a
click!
<br/>
<small class="text-muted">
You need to install Docker and
<a href='https://waha.devlike.pro/docs/how-to/install/' target='_blank'>
run the API in a click!
</a>
<br />
<small class='text-muted'>
It's actually "a command", not a click.
</small>
</p>
</div>
<div class="col-lg-5">
<h2 class="h4">No blocking</h2>
<div class='col-lg-5'>
<img src='/images/icons/checked.png' alt='Checked' style='width: 5rem'>
<h2 class='h4'>No blocking</h2>
<p>
Under the hood it runs a real instance of Whatsapp Web to avoid getting blocked.
<br/>
<small class="text-muted">
<a href='https://waha.devlike.pro/docs/how-to/engines/' target='_blank'>
Under the hood
</a>
it runs a real instance of Whatsapp Web to avoid getting blocked.
<br />
<small class='text-muted'>
WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered
totally safe.
</small>
@@ -85,9 +110,9 @@
{{ end }}
{{ define "sidebar-footer" }}
<section class="section section-sm container-fluid">
<div class="row justify-content-center text-center">
<div class="col-lg-9">
<section class='section section-sm container-fluid'>
<div class='row justify-content-center text-center'>
<div class='col-lg-9'>
{{- .Content -}}
</div>
</div>
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

+3
View File
@@ -24,6 +24,7 @@
"dependencies": {
"@adiwajshing/baileys": "github:WhiskeySockets/Baileys",
"@adiwajshing/keyed-db": "^0.2.4",
"@nestjs/axios": "^3.0.2",
"@nestjs/common": "^9.0.9",
"@nestjs/config": "^0.5.0",
"@nestjs/core": "^9.0.9",
@@ -31,8 +32,10 @@
"@nestjs/platform-express": "^9.0.9",
"@nestjs/serve-static": "^2.1.3",
"@nestjs/swagger": "^7.1.11",
"@nestjs/terminus": "^10.2.3",
"@types/lodash": "^4.14.194",
"@types/ws": "^8.5.4",
"check-disk-space": "^3.4.0",
"class-validator": "^0.12.2",
"del": "^6.0.0",
"express-basic-auth": "^1.2.1",
+17
View File
@@ -0,0 +1,17 @@
import { Controller, Get } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { HealthCheck } from '@nestjs/terminus';
import { WAHAHealthCheckService } from '../core/abc/WAHAHealthCheckService';
@Controller('health')
@ApiTags('other')
export class HealthController {
constructor(private wahaHealth: WAHAHealthCheckService) {}
@Get()
@HealthCheck()
async check() {
return this.wahaHealth.check();
}
}
+21
View File
@@ -155,4 +155,25 @@ export class WhatsappConfigService {
getSwaggerAdvancedConfigEnabled(): boolean {
return this.configService.get('WHATSAPP_SWAGGER_CONFIG_ADVANCED', false);
}
getHealthMediaFilesThreshold(): number {
return this.configService.get<number>(
'WHATSAPP_HEALTH_MEDIA_FILES_THRESHOLD_MB',
100,
);
}
getHealthSessionFilesThreshold(): number {
return this.configService.get<number>(
'WHATSAPP_HEALTH_SESSION_FILES_THRESHOLD_MB',
100,
);
}
getHealthMongoTimeout(): number {
return this.configService.get<number>(
'WHATSAPP_HEALTH_MONGO_TIMEOUT_MS',
3000,
);
}
}
+18
View File
@@ -0,0 +1,18 @@
import { ConsoleLogger, Injectable } from '@nestjs/common';
import { DiskHealthIndicator, HealthCheckService } from '@nestjs/terminus';
import type { HealthCheckResult } from '@nestjs/terminus/dist/health-check/health-check-result.interface';
import { WhatsappConfigService } from '../../config.service';
import { SessionManager } from './manager.abc';
@Injectable()
export abstract class WAHAHealthCheckService {
constructor(
protected sessionManager: SessionManager,
protected health: HealthCheckService,
protected log: ConsoleLogger,
protected config: WhatsappConfigService,
) {}
abstract check(): Promise<HealthCheckResult>;
}
+10
View File
@@ -2,12 +2,14 @@ import { ConsoleLogger, Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { PassportModule } from '@nestjs/passport';
import { ServeStaticModule } from '@nestjs/serve-static';
import { TerminusModule } from '@nestjs/terminus';
import { AuthController } from '../api/auth.controller';
import { ChatsController } from '../api/chats.controller';
import { ChattingController } from '../api/chatting.controller';
import { ContactsController } from '../api/contacts.controller';
import { GroupsController } from '../api/groups.controller';
import { HealthController } from '../api/health.controller';
import { PresenceController } from '../api/presence.controller';
import { ScreenshotController } from '../api/screenshot.controller';
import {
@@ -18,6 +20,8 @@ import { StatusController } from '../api/status.controller';
import { VersionController } from '../api/version.controller';
import { WhatsappConfigService } from '../config.service';
import { SessionManager } from './abc/manager.abc';
import { WAHAHealthCheckService } from './abc/WAHAHealthCheckService';
import { WAHAHealthCheckServiceCore } from './health/WAHAHealthCheckServiceCore';
import { SessionManagerCore } from './manager.core';
export const IMPORTS = [
@@ -38,6 +42,7 @@ export const IMPORTS = [
},
}),
PassportModule,
TerminusModule,
];
export const CONTROLLERS = [
AuthController,
@@ -51,12 +56,17 @@ export const CONTROLLERS = [
PresenceController,
ScreenshotController,
VersionController,
HealthController,
];
const PROVIDERS = [
{
provide: SessionManager,
useClass: SessionManagerCore,
},
{
provide: WAHAHealthCheckService,
useClass: WAHAHealthCheckServiceCore,
},
WhatsappConfigService,
ConsoleLogger,
];
@@ -0,0 +1,12 @@
import { Injectable } from '@nestjs/common';
import { HealthCheckResult } from '@nestjs/terminus';
import { WAHAHealthCheckService } from '../abc/WAHAHealthCheckService';
import { AvailableInPlusVersion } from '../exceptions';
@Injectable()
export class WAHAHealthCheckServiceCore extends WAHAHealthCheckService {
check(): Promise<HealthCheckResult> {
throw new AvailableInPlusVersion();
}
}
+34
View File
@@ -0,0 +1,34 @@
/**
* An errors which gets raised when the timeout
* exceeded
*
* @internal
*/
export class TimeoutError extends Error {}
/**
* Executes a promise in the given timeout. If the promise
* does not finish in the given timeout, it will
* raise a TimeoutError
*
* @param {number} ms The timeout in milliseconds
* @param {Promise<any>} promise The promise which should get executed
*
* @internal
*/
export const promiseTimeout = function (
ms: number,
promise: Promise<any>,
): Promise<any> {
let timer: NodeJS.Timeout;
return Promise.race([
promise,
new Promise(
(_, reject) =>
(timer = setTimeout(
() => reject(new TimeoutError(`Timed out in ${ms}ms.`)),
ms,
)),
),
]).finally(() => clearTimeout(timer));
};
+1 -1
View File
@@ -33,7 +33,7 @@ export function getEngineName(): string {
}
export const VERSION: WAHAEnvironment = {
version: '2024.2.3',
version: '2024.2.4',
engine: getEngineName(),
tier: getWAHAVersion(),
browser: getBrowserExecutablePath(),
+77 -1
View File
@@ -955,6 +955,17 @@ __metadata:
languageName: node
linkType: hard
"@nestjs/axios@npm:^3.0.2":
version: 3.0.2
resolution: "@nestjs/axios@npm:3.0.2"
peerDependencies:
"@nestjs/common": ^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0
axios: ^1.3.1
rxjs: ^6.0.0 || ^7.0.0
checksum: 285a735fb5db602b63aa4a37e161f609b2cec05b69f4bffe983617c2136ac29c0a33bb96e6276d22a656907bed5d53460e740310bc05c043dcd39c37db7cda29
languageName: node
linkType: hard
"@nestjs/cli@npm:^9.0.0":
version: 9.5.0
resolution: "@nestjs/cli@npm:9.5.0"
@@ -1153,6 +1164,61 @@ __metadata:
languageName: node
linkType: hard
"@nestjs/terminus@npm:^10.2.3":
version: 10.2.3
resolution: "@nestjs/terminus@npm:10.2.3"
dependencies:
boxen: 5.1.2
check-disk-space: 3.4.0
peerDependencies:
"@grpc/grpc-js": "*"
"@grpc/proto-loader": "*"
"@mikro-orm/core": "*"
"@mikro-orm/nestjs": "*"
"@nestjs/axios": ^1.0.0 || ^2.0.0 || ^3.0.0
"@nestjs/common": ^9.0.0 || ^10.0.0
"@nestjs/core": ^9.0.0 || ^10.0.0
"@nestjs/microservices": ^9.0.0 || ^10.0.0
"@nestjs/mongoose": ^9.0.0 || ^10.0.0
"@nestjs/sequelize": ^9.0.0 || ^10.0.0
"@nestjs/typeorm": ^9.0.0 || ^10.0.0
"@prisma/client": "*"
mongoose: "*"
reflect-metadata: 0.1.x || 0.2.x
rxjs: 7.x
sequelize: "*"
typeorm: "*"
peerDependenciesMeta:
"@grpc/grpc-js":
optional: true
"@grpc/proto-loader":
optional: true
"@mikro-orm/core":
optional: true
"@mikro-orm/nestjs":
optional: true
"@nestjs/axios":
optional: true
"@nestjs/microservices":
optional: true
"@nestjs/mongoose":
optional: true
"@nestjs/sequelize":
optional: true
"@nestjs/typeorm":
optional: true
"@prisma/client":
optional: true
mongoose:
optional: true
sequelize:
optional: true
typeorm:
optional: true
checksum: 7a758c845c0a07a75230731d3b638919aae0b503b6cef97fa7f63d4cd23c6c6db0e8d39d5ecf4d8fda6e3f0aa7d4aa95fddcf5868758cf85d201db6acc43ac9d
languageName: node
linkType: hard
"@nestjs/testing@npm:^9.0.9":
version: 9.4.3
resolution: "@nestjs/testing@npm:9.4.3"
@@ -3216,7 +3282,7 @@ __metadata:
languageName: node
linkType: hard
"boxen@npm:^5.1.1":
"boxen@npm:5.1.2, boxen@npm:^5.1.1":
version: 5.1.2
resolution: "boxen@npm:5.1.2"
dependencies:
@@ -3592,6 +3658,13 @@ __metadata:
languageName: node
linkType: hard
"check-disk-space@npm:3.4.0, check-disk-space@npm:^3.4.0":
version: 3.4.0
resolution: "check-disk-space@npm:3.4.0"
checksum: 0154c149c34a1233fe542f2a9f9ea2526bb90169489259eda8de1cf6870f765e8f5299c3b085085cc1ef33d9559f589fd10609c7e52d2e624ef6b5720dd9743c
languageName: node
linkType: hard
"cheerio-select@npm:^2.1.0":
version: 2.1.0
resolution: "cheerio-select@npm:2.1.0"
@@ -13216,6 +13289,7 @@ __metadata:
dependencies:
"@adiwajshing/baileys": "github:WhiskeySockets/Baileys"
"@adiwajshing/keyed-db": ^0.2.4
"@nestjs/axios": ^3.0.2
"@nestjs/cli": ^9.0.0
"@nestjs/common": ^9.0.9
"@nestjs/config": ^0.5.0
@@ -13225,6 +13299,7 @@ __metadata:
"@nestjs/schematics": ^9.0.1
"@nestjs/serve-static": ^2.1.3
"@nestjs/swagger": ^7.1.11
"@nestjs/terminus": ^10.2.3
"@nestjs/testing": ^9.0.9
"@types/express": ^4.17.3
"@types/jest": 26.0.10
@@ -13234,6 +13309,7 @@ __metadata:
"@types/ws": ^8.5.4
"@typescript-eslint/eslint-plugin": 3.9.1
"@typescript-eslint/parser": 3.9.1
check-disk-space: ^3.4.0
class-validator: ^0.12.2
del: ^6.0.0
eslint: 7.7.0