All Projects → cuillerejs → cuillere

cuillerejs / cuillere

Licence: Apache-2.0 license
CuillereJS is an extensible asynchronous execution framework based on generator functions.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to cuillere

jducers
A js transducers-like implementation using ES9
Stars: ✭ 25 (+92.31%)
Mutual labels:  generator-functions


Welcome to CuillereJS 🥄

Version License: Apache-2.0

CuillereJS is an extensible asynchronous execution framework based on generator functions.

🚧 CuillereJS is still experimental, APIs may change at any time.

Why ?

The goal of CuillereJS is to abstract some inevitable technical complexity (such as managing database transactions) in plugins, and keep business code as simple and focused as possible.

Usage

In this example we use CuillereJS to manage the connection to a PostgreSQL database.

const cuillere = require('@cuillere/core')
const { poolPlugin, transactionPlugin, queryPlugin } = require('@cuillere/postgres')

const cllr = cuillere(
  poolPlugin({ /* postgres config */ }), // Manages connection pool
  transactionPlugin(), // Manages transactions
  queryPlugin() // Executes queries
)

const addUserAddress = (userId, address, setDefault) => cllr.call(function*() {
  const res = yield query({
    text: `INSERT INTO addresses (userId, street, postalcode, city)
           VALUES ($1, $2, $3, $4)
           RETURNING *`,
    values: [userId, address.street, address.postalCode, address.city]
  })
  if (setDefault) {
    const addressId = res.rows[0].id
    yield query({
      text: `UPDATE users
             SET defaultaddressid = $1
             WHERE userid = $2`,
      values: [addressId, userId]
    })
  }
})

Install

yarn add @cuillere/core

Authors

👤 Valentin Cocaud

👤 Nicolas Lepage

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 CuillereJS.
This project is Apache-2.0 licensed.


This README was generated with ❤️ by readme-md-generator

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].