Skip to content

Commit

Permalink
complete routes
Browse files Browse the repository at this point in the history
  • Loading branch information
ookamiiixd committed Jan 6, 2023
1 parent 5fbdf13 commit 6ede4e6
Show file tree
Hide file tree
Showing 28 changed files with 3,372 additions and 183 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ PORT="3000"
DATABASE_URL="mysql://root:12345@localhost:3306/baileys_api"
RECONNECT_INTERVAL="5000"
MAX_RECONNECT_RETRIES="5"
SSE_MAX_QR_GENERATION="10"
SSE_MAX_QR_GENERATION="10"
LOG_LEVEL="warn"
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
},
};
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: ['https://paypal.me/ookamiiixd', 'https://trakteer.id/ookamiiixd']
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules/
dist/
debug/
.env
prisma/migrations/
.env
*.tgz
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
dist/
debug/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Royhan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Baileys API

An implementation of [@adiwajshing/Baileys](https://github.com/adiwajshing/Baileys) as a simple REST API with multiple device support

## Requirements

- **NodeJS** version **14.5.0** or higher

## Installation

1. Download or clone this repo. If you want to skip the build step, you can download the prebuilt one from the release page
1. Enter to the project directory
1. Install the dependencies
1. Build the project using the `build` script. 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. Run your [migration](https://www.prisma.io/docs/reference/api-reference/command-reference#prisma-migrate). Don't forget to always re-run your migration whenever there's a change on the `prisma/` directory

## `.env` Configurations

```env
# Listening Host
HOST="localhost"
# Listening Port
PORT="3000"
# 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 to build the project first using the `build` script
1. You can then start the app using the `start` script
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 to use 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**
Binary file removed external/baileys-store-4.tgz
Binary file not shown.
20 changes: 12 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@
"version": "1.0.0-beta.0",
"private": true,
"main": "dist/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/ookamiiixd/baileys-api.git"
},
"author": "ookamiiixd <[email protected]>",
"repository": "github:ookamiiixd/baileys-api",
"author": "Royhan (https://github.com/ookamiiixd)",
"bugs": {
"url": "https://github.com/ookamiiixd/baileys-api/issues"
},
"homepage": "https://github.com/ookamiiixd/baileys-api#readme",
"license": "MIT",
"scripts": {
"start": "node .",
"build": "tsc",
"lint": "eslint .",
"format": "prettier . --write"
},
"dependencies": {
"@adiwajshing/baileys": "https://github.com/ookamiiixd/Baileys.git#build",
"baileys-store": "file:external/baileys-store-4.tgz",
"@adiwajshing/baileys": "^5.0.0",
"@hapi/boom": "^10.0.0",
"@ookamiiixd/baileys-store": "^1.0.0-beta.0",
"@prisma/client": "^4.7.1",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
Expand All @@ -45,11 +43,17 @@
"eslint": "^8.29.0",
"eslint-config-prettier": "^8.5.0",
"prettier": "^2.8.0",
"prettier-plugin-organize-imports": "^3.2.1",
"prisma": "^4.7.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
},
"engines": {
"node": ">=14.5.0"
}
},
"files": [
"dist/",
"prisma/schema.prisma",
".env.example"
]
}
Loading

0 comments on commit 6ede4e6

Please sign in to comment.