https://github.com/asheswook/tranjs
Declarative transaction management without ORMs
https://github.com/asheswook/tranjs
database nodejs transaction transactional typescript
Last synced: about 1 year ago
JSON representation
Declarative transaction management without ORMs
- Host: GitHub
- URL: https://github.com/asheswook/tranjs
- Owner: asheswook
- License: lgpl-2.1
- Created: 2024-12-27T06:24:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-19T01:43:49.000Z (over 1 year ago)
- Last Synced: 2025-04-12T02:18:02.446Z (about 1 year ago)
- Topics: database, nodejs, transaction, transactional, typescript
- Language: TypeScript
- Homepage:
- Size: 150 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TranJS
[](https://github.com/asheswook/tranjs/actions/workflows/test.yml)
TranJS is a transaction management framework which provides declaretive transaction, without any ORMs.
It is designed to provide reliable and intuitive transaction management for mission-critical safety applications and general-purpose applications.
## Features
- ✅ **Declarative Transaction via Decorator**
- ⚡ **TypeScript Native**
- 🛠️ **No Dependencies, Lightweight (15KB)**
- 🔄 **Flexible Transaction Propagation**
## Getting Started
* API Documentation is available at [here](/docs/api.md).
* Native supported drivers are available at [here](/docs/drivers.md).
* The [example](/examples) contains a simple example of how to use the TranJS framework.
## Usage
```typescript
class MyService {
@Transactional()
async transfer(from: string, to: string, amount: number) {
await this.withdrawMoney("Jaewook", 100);
await this.depositMoney("Chansu", 100);
}
@Transactional(Propagation.MANDATORY)
private async depositMoney(userId: string, amount: number) {
console.log("Execute Query", userId, amount);
await ctx().execute("UPDATE user SET balance = balance + ? WHERE id = ?", [amount, userId]);
}
@Transactional(Propagation.MANDATORY)
private async withdrawMoney(userId: string, amount: number) {
console.log("Execute Query", userId, amount);
await ctx().execute("UPDATE user SET balance = balance - ? WHERE id = ?", [amount, userId]);
}
}
```
```bash
Start Transaction (id: ae8wml5i78rt) # Transaction started at transfer()
Execute Query Jaewook 100
Execute Query Chansu 100
Commit Transaction (id: ae8wml5i78rt) # Transaction committed when transfer() finished
```
## Installation
It should be set up for the database you want to use. See [here](/docs/drivers.md).
> [!NOTE]
> If the driver you want to use does not exist, [you can implement it on your own.](/docs/self-implement-guide.md)
## Contribute
TranJS welcomes contributions from the community to enhance its functionality and usability. Here’s how you can contribute:
1. **Report Issues**
If you encounter bugs or have suggestions for improvements, feel free to open an issue in the repository.
2. **Submit Pull Requests**
Fork the repository, create a new branch for your changes, and submit a pull request. Ensure your code adheres to the project's coding standards and includes relevant tests.
3. **Implement Drivers**
If the driver you need is not available, you can implement it yourself using the [self-implement guide](/docs/self-implement-guide.md).
4. **Improve Documentation**
Contributions to the documentation are always appreciated—whether it's fixing typos, adding examples, or clarifying complex concepts.
5. **Collaborate and Review**
Participate in discussions, review pull requests, and provide constructive feedback to other contributors.
## License
This project is licensed under the LGPL-2.1 License - see the [LICENSE](LICENSE) file for details.
## Acknowledgement
* [Spring JPA](https://github.com/spring-projects/spring-data-jpa)