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

rebill

v1.1.0

Published

A Pure JavaScript SDK to integrate Rebill into your web or ecosystem

Downloads

9

Readme

Rebill SDK :rocket:

As we previously mentioned, this repository contains all the logic attributed to the SDK. Its main function is the initialization of the new SDK instance and sending messages to the iframe.

Its action is fundamental since it allows the client to interact with the iframe without necessarily manipulating it. The communication follows this flow: client → sdk → iframe (we will detail the responsibilities of this iframe in rebill-elements-v3).

The V3 project is made with Typescript and built with Webpack. The resulting minified JS file is hosted in the AWS bucket named rebill-sdk-demo-[env], with env taking the value associated with its environment (stg or prod).

In the same repository, the infrastructure necessary for the npm package named rebill is hosted, which gathers and makes all this logic available. The package is deployed on npm through an action configured in the project.

Project Structure

Let's review directory by directory.

Outside of any folder in the project root, we have all the configuration files:

  • package.json
  • tsconfig.json
  • webpack.prod.js: responsible for building the code for deployment on AWS
  • webpack.config.js: responsible for building the code for the NPM package

Within /src live both the SDK V2 project, named as panthon-sdk, and also the V3 project simply called sdk.

We will not discuss the internal structure of the panthon-sdk directory since we no longer maintain this version, but we will detail the sdk folder associated with V3:

  • index.ts: is the SDK's entry point, and all the methods later made available to the client are defined in it.
  • constants.js: simply constants.
  • services: services consumed in the application.
  • schemas: type and interface definitions.

In the shared directory, there are common declarations for both SDK V2 and V3.

In npm-package, you'll find the structure associated with the NPM package. The rebill directory has the code that is later published as a downloadable package from NPM. The package allows the user to interact with all the functionality provided by the SDK, without the need to manually add a script tag to their HTML, but simply by downloading the library with their package manager. The test directory serves only to locally test the package before publishing it.

In dist is the js minified file that is later uploaded to the S3 bucket and is made available to clients as an option to consume the SDK.

In demo, examples of the SDK use cases are hosted for local testing.

Usage

To use the project locally, simply add a script tag to the HTML in which you want to work and start using the methods exposed in the index.ts file of the sdk directory, as shown in the demos hosted in the demo directory.

To see the changes made in the code reflected, you need to rebuild the entire project with the build command, described in the package.json. After a build, the /dist/v3/rebill.min.js and /npm-package/rebill/ files are created.

env file

To use the project locally, you need the following environment variable configuration file:

LOCAL_ELEMENT=http://localhost:3006/v3/
API_BASE=http://localhost:8000
SDK_REBILL_GATEWAY=https://secure.rebill.dev

With LOCAL_ELEMENT being the variable associated with the iframe URL. If running locally, in conjunction with Rebill Elements, the value set in the previous code snippet should be used. API_BASE refers to the URL associated with the backend where requests will be made, and lastly, SDK_REBILL_GATEWAY is the parameter associated with the anti-fraud engine that runs with each transaction.

Build and Workflows

The project has two workflows that run upon making a push to the main branch:

  • deployment.yaml: responsible for deploying to the S3 bucket. Both for stg and for