transaction-client
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Transaction Client

Description

A transaction client to ensure all logical steps in an atomic transaction are completed or rolled back.

Use

Install

yarn add transaction-client

Example

import { TransactionClient, TransactionStep } from 'transaction-client';

const client = new TransactionClient();

const getFirstTodoItem = new TransactionStep('fetchRoleFromDb', async () => ({
  todo1: await fetch('https://jsonplaceholder.typicode.com/todos/1'),
}));

const getSecondTodoItem = new TransactionStep('fetchRoleFromDb', async () => ({
  todo2: await fetch('https://jsonplaceholder.typicode.com/todos/2'),
}));

const data = client
  .addStep(getFirstTodoItem)
  .addStep(getSecondTodoItem)
  .start({ checkErrors: true })
  .then(({ todo1, todo2 }) => {
    console.log({ todo1, todo2 });
  });

Development

Dependencies

The following dependencies must be available on your machine:

  • node @ ^8.10.0 || ^10.13.0 || >=11.10.1
  • yarn @ ^1.17

Local Setup

  1. Run yarn install to install package dependencies
  2. Run yarn test to ensure that tests are passing
  3. Run yarn dev to build TypeScript with hot reloading
  4. Make changes to package

Contributing

Contributions are welcome. Please read CONTRIBUTING.md for code of conduct details, and the process for submitting pull requests.

License

This project is licensed under the GNU GPL 3 License - see the LICENSE file for details.

Readme

Keywords

none

Package Sidebar

Install

npm i transaction-client

Weekly Downloads

2

Version

1.0.2

License

GPL-3.0-only

Unpacked Size

113 kB

Total Files

36

Last publish

Collaborators

  • torywalker