Skip to content

duffelhq/duffel-api-javascript

Repository files navigation

Duffel API JavaScript Client

A JavaScript client library for the Duffel API.

Content

Prerequisites

  • Node >= 18.16.0

Install

You can install the dependencies for this library by executing the following command:

yarn install

Test

You can run the test suite for this library by executing the following command:

yarn test

Lint

You can run the linters configured for this library by executing the following command:

yarn lint

Installation

You can install this library into your current project by executing the following command:

yarn add @duffel/api

If you need to create a new API operation class, just type yarn generate:operation and you will be prompted with a few questions. This script will create the relevant operation folder and files for you.

Committing to the repository

To be able to publish the correct version to npm, this project is currently following Angular conventional commit message guidelines which is based on conventional commits. This commit message guideline allows the semantic-release GitHub action to be triggered.

CommitLint to the rescue

Before creating a commit you should run a husky hook which will check if the commit structure is valid or not. If you don't want to create the commit manually, you can use yarn commit which will use commitzen to help you out creating the message.

Client CI

Every time a commit is merged to main, a GitHub Action is run to analyse the commit messages with semantic-release and automatically update the current version to be deployed by following semantic versioning. When the deployment is complete, the action updates the package version, using Duffel's machine user (@duffel-bot) as the author, and this change will be automatically approved by the GitHub Action via the [autoapprove workflow] (../.github/workflows/autoapprove.yml).

Continuous Integration

  1. Developer opens pull request to main
  2. Pull request is merged
  3. GitHub Actions are triggered and the commits are analysed
    • if there's a breaking change, bump the major version
    • if there's a feature commit, bump the minor version
    • if there's a fix, bump the patch version
  4. Deploy the new version a. Publish to npm b. Create and push a git tag c. Publish a GitHub release with the relevant commits and descriptions
  5. After the release is published then a pull request is automatically created and approved via a GitHub Action to bump the package version

Documentation

You can learn more about the Duffel API and this library in our documentation.