npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bananas-commerce

v2.6.3

Published

A client for bananas-commerce with support for TypeScript

Downloads

1,173

Readme

bananas-commerce

The JavaScript client for bananas-commerce.

import * as bcom from "bananas-commerce";

const client = generateBcomClient({
  baseUrl: "https://bcom.example.com",
  config: {
    countryCode: "SE",
    siteCode: "SE",
  },
  extensions: [
    new ObayatyBcomExtension(),
    new Extensions.Pos(),
    new Extensions.Webshipper(),
    new Extensions.Adyen(),
  ],
});

const checkout = await client.adyen.begin({
  checkoutSession: "..",
});

Prerequisites

Prerequisites apart from having the whole bcom repo cloned and the prerequisites for running the backend is only deno unless you want to publish a new version to npm, but that should not be needed as CI takes care of that.

Coverage

If you want to generate cobertura coverage locally you need two additional dependencies installed locally from pip: lcov_cobertura and pycobertura. The default behaviour of deno task test:coverage is to generate a cobertura report but that comes with a >50% performance hit because of the lcov to cobertura coverage format conversion (not that it is a huge problem, it's about 0.5s...).

If you want coverage reporting locally without using either lcov or cobertura, simply run deno task test:coverage.

Building

When testing and running in deno no build step is required, if however you wish to build a new version of the npm package you will have to run:

$ deno task generate:client

This generates the npm/ directory which contains all relevant builds (commonjs, browser and types) along with a package.json with the correct entrypoints for using either or both of the BananasCommerce and BananasCommercePrivate clients. It is done using the dnt (deno-to-node) build tool.

Generating fresh schemas

The automatically generated schema definitions are generated using the openapi-typescript tool. This is done automatically with:

# Build your docker image, this will be the version from which the client is generated from
$ task docker:builder
$ deno task generate:schemas

Formatting, linting and testing

All of these steps are made using the corresponding deno commands:

deno fmt
deno lint
deno task test

When running these commands along with the deno task generate:client command typechecking is automatically done to ensure the typescript types are correct.

Project structure

│ # AUTOMATICALLY GENERATED FILES #########################################################################
├── npm/                - An automatically generated node package! DO EDIT MANUALLY!
├── coverage/           - An automatically generated v8 coverage report used for generating the lcov report
├── coverage.lcov       - A lcov coverage report generated as an in-between format for generating cobertura
├── coverage.xml        - A cobertura coverage report generated from the lcov report
│ #########################################################################################################
├── scripts/            - A directory containing all development scripts
│   └── npm.ts          - This script uses dnt to automatically create the npm package
├── src/                - This directory contains all of the client and related utilities
│   ├── extensions/     - Each "extension" corresponds to a bcom "app", for example POS
│   ├── types/          - Automatically generated types from the OpenAPI json schemas
│   ├── util/           - Utilities
│   ├── api.ts          - A base class from which all extensions extend
│   ├── client.ts       - A factory (`generateClient`) which combines extensions and configuration into the client
│   ├── extension.ts    - Scaffolding types which are used by extensions
│   └── mod.ts          - The primary entrypoint
├── mock/               - Mocking utils for writing tests
└── test/               - Tests for the bananas-commerce client

Misc, links and stuff to remember