Skip to content

Commit

Permalink
Merge pull request #11 from mimamch/dev-session
Browse files Browse the repository at this point in the history
update v3.2.0
  • Loading branch information
mimamch committed Jul 10, 2023
2 parents 130ff6e + 15d5968 commit d88e4b2
Show file tree
Hide file tree
Showing 8 changed files with 1,553 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
PORT=5001
PORT=5001
KEY=mysupersecretkey # For Securing Some Data
57 changes: 57 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
## Contributing Guidelines

Thank you for considering contributing to the `@mimamch/wa-gateway` library! We welcome your contributions and appreciate your support. To ensure a smooth collaboration process, please follow these guidelines when contributing to the project.

### Bug Reports and Feature Requests

If you encounter a bug or have a feature request, please open an issue on the [GitHub issue tracker](https://github.com/mimamch/cmd/issues). When reporting a bug, provide detailed information about the issue, including steps to reproduce it. For feature requests, clearly describe the new functionality you would like to see in the library.

### Pull Requests

We welcome pull requests for bug fixes, enhancements, and new features. Before submitting a pull request, please ensure that:

1. You have forked the repository and created a new branch for your changes.
2. Your code follows the project's coding style and conventions.
3. You have added appropriate tests to cover your changes.
4. All existing tests pass successfully.
5. Your commits are descriptive and include a clear explanation of the changes.

To submit a pull request, follow these steps:

1. Fork the repository on GitHub.
2. Clone your forked repository to your local machine.
3. Create a new branch for your changes: `git checkout -b my-feature`.
4. Make your changes and commit them: `git commit -m "Add new feature"`.
5. Push your branch to your forked repository: `git push origin my-feature`.
6. Open a pull request on the official repository's GitHub page.

### Development Setup

To set up the development environment and start working on the library, follow these steps:

1. Clone the repository: `git clone https://github.com/mimamch/cmd.git`.
2. Install the project dependencies: `npm install`.
3. Run tests to ensure everything is working: `npm test`.
4. Make your changes and add tests for them.
5. Run tests again to verify that everything is still working: `npm test`.
6. Commit your changes and push to your forked repository.
7. Open a pull request following the guidelines mentioned above.

### Code Style and Conventions

We strive to maintain a clean and consistent codebase. Please adhere to the following guidelines when contributing to the project:

- Use meaningful and descriptive variable and function names.
- Follow the existing code formatting and indentation style.
- Ensure your code is properly commented and documented.
- Write clear commit messages that explain the purpose of each commit.

### License

By contributing to this project, you agree that your contributions will be licensed under the MIT License. Make sure you understand and agree to the licensing terms before submitting your pull request.

### Code of Conduct

Please note that by participating in this project, you are expected to follow the [Code of Conduct](CODE_OF_CONDUCT.md). Be respectful and considerate towards others, and maintain a positive and inclusive environment for collaboration.

We appreciate your contributions and look forward to your involvement in improving the `@mimamch/wa-gateway` library!
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
MIT License

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.
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Multi Session Whatsapp Gateway NodeJS
# Headless Multi Session Whatsapp Gateway NodeJS

A multi session Whatsapp Gateway with NodeJS
Easy Setup Headless multi session Whatsapp Gateway with NodeJS

- Support multi device
- Support multi session / multi phone number
Expand All @@ -17,6 +17,7 @@ To run this project, you will need to add the following environment variables to
// .env
PORT=5001 // which port to running on your machine
KEY=mysupersecretkey # For Securing Some Data
```

## Install and Running
Expand Down Expand Up @@ -97,3 +98,33 @@ Open On Browser & Start New Session
| Parameter | Type | Description |
| :-------- | :------- | :------------------------------------- |
| `session` | `string` | **Required**. Create Your Session Name |

#### Get All Session ID

```
GET /sessions?key=mysupersecretkey
```

| Parameter | Type | Description |
| :-------- | :------- | :------------------------------- |
| `key` | `string` | **Required**. Key on ".env" file |

## Changelog

V3.2.0

- Add Get All Session ID
- Add Key for secret data
- Update README.md

## Documentation

For detailed documentation, including guides and API references, please visit the [official documentation](https://github.com/mimamch/wa-gateway).

## Contributing

Contributions are welcome! Please follow the guidelines outlined in the [CONTRIBUTING.md](https://github.com/mimamch/wa-gateway/blob/main/CONTRIBUTING.md) file.

## License

This library is licensed under the [MIT License](https://github.com/mimamch/wa-gateway/blob/main/LICENSE).
14 changes: 14 additions & 0 deletions app/controllers/session_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,17 @@ exports.deleteSession = async (req, res, next) => {
next(error);
}
};
exports.sessions = async (req, res, next) => {
try {
const key = req.body.key || req.query.key || req.headers.key;

// is KEY provided and secured
if (process.env.KEY && process.env.KEY != key) {
throw new ValidationError("Invalid Key");
}

res.status(200).json(responseSuccessWithData(whatsapp.getAllSession()));
} catch (error) {
next(error);
}
};
2 changes: 2 additions & 0 deletions app/routers/session_router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ const { Router } = require("express");
const {
createSession,
deleteSession,
sessions,
} = require("../controllers/session_controller");

const SessionRouter = Router();

SessionRouter.all("/start-session", createSession);
SessionRouter.all("/delete-session", deleteSession);
SessionRouter.all("/sessions", sessions);

module.exports = SessionRouter;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "baileys",
"version": "3.1.0",
"version": "3.2.0",
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js --ignore ./wa_credentials --ignore ./public",
Expand Down
Loading

0 comments on commit d88e4b2

Please sign in to comment.