Git Product home page Git Product logo

wagate's Introduction

WA-GATE

A very simple typescript whatsapp gateway via expressjs REST API using whatsapp-web.js

Contribution

Any features request and contribution are welcome! ^_^

Installation & Configuration

Configuration

  1. Make sure you clone this repo first
  2. Copy .env.example and rename it to .env
  3. Change the configuration there
  4. Don't forget to change the logo.jpg in the root directory

Installation

  1. Node.js v20+ , I've setups to 20 in package.json, you can change it but generally it works in Node.js v12 higher
  2. pnpm package manager, because why not
  3. You can go for docker for an easy setups, or if you deploy it manually you will need to install Google Chrome
  4. On an Ubuntu server, you will need to run this command:
sudo apt-get update && sudo apt-get install -y \
    gconf-service \
    libgbm-dev \
    libasound2 \
    libatk1.0-0 \
    libc6 \
    libcairo2 \
    libcups2 \
    libdbus-1-3 \
    libexpat1 \
    libfontconfig1 \
    libgcc1 \
    libgconf-2-4 \
    libgdk-pixbuf2.0-0 \
    libglib2.0-0 \
    libgtk-3-0 \
    libnspr4 \
    libpango-1.0-0 \
    libpangocairo-1.0-0 \
    libstdc++6 \
    libx11-6 \
    libx11-xcb1 \
    libxcb1 \
    libxcomposite1 \
    libxcursor1 \
    libxdamage1 \
    libxext6 \
    libxfixes3 \
    libxi6 \
    libxrandr2 \
    libxrender1 \
    libxss1 \
    libxtst6 \
    ca-certificates \
    fonts-liberation \
    libappindicator1 \
    libnss3 \
    lsb-release \
    xdg-utils \
    wget
  1. cd into the project directory
  2. run pnpm install
  3. run pnpm build
  4. run pnpm start
  5. After that you will need to scan the QR that is printed to the terminal
  6. You're basically done, or if you want to be more robust, you can use pm2 for a better process management

Removing delay

You can commented out this line https://github.com/snowfluke/wagate/blob/fdbf04baae84d2d8414f03e67df218cbfab1de0b/lib/wagate-client.ts#L57 and also this line https://github.com/snowfluke/wagate/blob/fdbf04baae84d2d8414f03e67df218cbfab1de0b/lib/wagate-client.ts#L62

Endpoints

  • [GET] /api/v1/

Response:

{
  "message": "REST API is working"
}
  • [POST][Multipart/form-data] /api/v1/send/
name value
number 628XXX...
content your message

Response:

{
  "status": "success",
  "code": 200,
  "message": "Message sucessfully sent",
  "data": {
    "number": "628XXX...",
    "content": "Hi, mom!",
    "type": "text"
  }
}
  • [POST][Multipart/form-data] /api/v1/send/media
name value
number 628XXX...
content your message
file binary file

Response:

{
  "status": "success",
  "code": 200,
  "message": "Message sucessfully sent",
  "data": {
    "number": "628XXX...",
    "content": "this is your media caption",
    "type": "media"
  }
}

Error response

{
  "status": "error",
  "code": 400,
  "message": "Bad Image"
}

Error code

Code Status
200 SUCCESS
201 CREATED
204 NO CONTENT
400 BAD REQUEST
401 UNAUTHORIZED
403 FORBIDDEN
404 NOT FOUND
408 TIME OUT
429 TOO MANY REQUEST
500 INTERNAL SERVER ERROR
503 SERVICE UNAVAILABLE

wagate's People

Contributors

snowfluke avatar zeejkt48 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.