-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e5ac19
commit 3841325
Showing
41 changed files
with
9,124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
HOST="localhost" | ||
PORT="3000" | ||
NODE_ENV="development" | ||
DATABASE_URL="mysql://root:nizar@localhost:3406/baileys_api" | ||
RECONNECT_INTERVAL="5000" | ||
MAX_RECONNECT_RETRIES="5" | ||
SSE_MAX_QR_GENERATION="10" | ||
LOG_LEVEL="warn" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true, | ||
}, | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint"], | ||
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"], | ||
rules: { | ||
semi: "error", | ||
quotes: ["error", "double"], | ||
"@typescript-eslint/consistent-type-imports": "error", | ||
"@typescript-eslint/no-unused-vars": "error", | ||
"@typescript-eslint/no-non-null-assertion": "off", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules/ | ||
dist/ | ||
debug/ | ||
prisma/migrations/ | ||
.env | ||
*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
dist/ | ||
debug/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Baileys API | ||
|
||
Baileys is a simple, fast and easy to use WhatsApp Web API written in TypeScript. It is designed to be simple to use and is optimized for usage in Node.js. | ||
|
||
An implementation of [@WhiskeySockets/Baileys](https://github.com/WhiskeySockets/Baileys) as a simple REST API with multiple device support | ||
|
||
Project continued from [@ookamiiixd/baileys-api](https://github.com/ookamiiixd/baileys-api/) | ||
|
||
## Requirements | ||
|
||
- NodeJS version 18.19.0 or higher | ||
- Prisma [supported databases](https://www.prisma.io/docs/reference/database-reference/supported-databases). Tested on MySQL and PostgreSQL | ||
|
||
## Installation | ||
|
||
1. Download or clone this repo. If you want to skip the build step, you can download the prebuilt one (file with the `baileys-api-VERSION.tgz` name pattern) from the release page | ||
2. Enter to the project directory | ||
3. Install the dependencies | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
4. Build the project using the `build` script | ||
|
||
```sh | ||
npm run build | ||
``` | ||
|
||
You can skip this part if you're using the prebuilt one from the release page | ||
|
||
## Setup | ||
|
||
1. Copy the `.env.example` file and rename it into `.env`, then update your [connection url](https://www.prisma.io/docs/reference/database-reference/connection-urls) in the `DATABASE_URL` field | ||
1. Update your [provider](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#fields) in the `prisma/schema.prisma` file if you're using database other than MySQL | ||
1. Run your [migration](https://www.prisma.io/docs/reference/api-reference/command-reference#prisma-migrate) | ||
|
||
```sh | ||
npx prisma migrate (dev|deploy) | ||
``` | ||
|
||
or push the schema | ||
|
||
```sh | ||
npx prisma db push | ||
``` | ||
|
||
Don't forget to always re-run those whenever there's a change on the `prisma/schema.prisma` file | ||
|
||
## `.env` Configurations | ||
|
||
```env | ||
# Listening Host | ||
HOST="localhost" | ||
# Listening Port | ||
PORT="3000" | ||
# Project Mode (development|production) | ||
NODE_ENV="development" | ||
# Database Connection URL | ||
DATABASE_URL="mysql://root:12345@localhost:3306/baileys_api" | ||
# Reconnect Interval (in Milliseconds) | ||
RECONNECT_INTERVAL="5000" | ||
# Maximum Reconnect Attempts | ||
MAX_RECONNECT_RETRIES="5" | ||
# Maximum SSE QR Generation Attempts | ||
SSE_MAX_QR_GENERATION="10" | ||
# Pino Logger Level | ||
LOG_LEVEL="warn" | ||
``` | ||
|
||
## Usage | ||
|
||
1. Make sure you have completed the **Installation** and **Setup** step | ||
1. You can then start the app using the `start` script | ||
|
||
```sh | ||
npm run start | ||
``` | ||
|
||
1. Now the endpoint should be available according to your environment variables configuration. Default is at `http://localhost:3000` | ||
|
||
## API Docs | ||
|
||
The API documentation is available online [here](https://documenter.getpostman.com/view/18988925/2s8Z73zWbg). You can also import the **Postman Collection File** `(postman_collection.json)` into your Postman App alternatively | ||
|
||
## Notes | ||
|
||
- There's no authentication, you may want to implement your own. I don't want to force anyone into using a specific authentication method, choose whatever you love | ||
|
||
## Notice | ||
|
||
This project is intended for learning purpose only, don't use it for spamming or any activities that's prohibited by **WhatsApp** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"name": "baileys-express", | ||
"version": "1.0.0-beta.0", | ||
"description": "baileys ", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"start": "node .", | ||
"dev": "nodemon src/index.ts", | ||
"lint": "eslint . --ext .ts", | ||
"format": "prettier . --write", | ||
"generate": "prisma generate" | ||
}, | ||
"keywords": [], | ||
"author": "Nizar", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@hapi/boom": "^10.0.1", | ||
"@prisma/client": "^5.10.2", | ||
"@whiskeysockets/baileys": "^6.6.0", | ||
"cors": "^2.8.5", | ||
"dotenv": "^16.4.5", | ||
"express": "^4.18.2", | ||
"express-validator": "^7.0.1", | ||
"link-preview-js": "^3.0.5", | ||
"long": "^5.2.3", | ||
"pino": "^7.11.0", | ||
"qrcode": "^1.5.3", | ||
"qrcode-terminal": "^0.12.0", | ||
"ws": "^8.16.0" | ||
}, | ||
"devDependencies": { | ||
"@types/cors": "^2.8.17", | ||
"@types/express": "^4.17.21", | ||
"@types/node": "^20.11.19", | ||
"@types/qrcode": "^1.5.5", | ||
"@types/ws": "^8.5.10", | ||
"@typescript-eslint/eslint-plugin": "^7.0.2", | ||
"@typescript-eslint/parser": "^7.0.2", | ||
"eslint": "^8.56.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"nodemon": "^3.0.3", | ||
"prettier": "^3.2.5", | ||
"prettier-plugin-organize-imports": "^3.2.4", | ||
"prisma": "^5.10.2", | ||
"ts-node": "^10.9.2", | ||
"tsconfig-paths": "^4.2.0", | ||
"typescript": "^5.3.3" | ||
}, | ||
"engines": { | ||
"node": ">=18.19.0" | ||
}, | ||
"files": [ | ||
"dist/", | ||
"prisma/schema.prisma", | ||
".env.example" | ||
] | ||
} |
Oops, something went wrong.