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

@gobend/jsdk

v0.12.2

Published

SDK for interacting with Bend data types

Downloads

72

Readme

Development

Steps for new developers to get up and running with the Bend data-service

Dependencies

You will need Rust, NodeJS, and a number of other tools to develop properly on the data-service

  1. Rust stable
  2. NodeJS LTS
  3. For formatting, you'll need rustfmt
  • rustup component add rustfmt

Setting up the database

  1. Install diesel for MySQL: cargo install diesel_cli --no-default-features --features mysql
  2. Copy example.env to .env and replace with PlanetScale database details
  3. Run diesel migration run

Seeding Data

Run scripts/seed_factors_and_categories.sql to initialize the following:
  1. Codat Factors
  2. MCC Factors
  3. UNSPSC Factors
  4. Bend categories
  5. Bend category to mcc mappings
Run scripts/seed_db.sql to initialize the following:
  1. a v0 privileged API key for local use
  2. default user accounts
  3. a Bend org with memberships for the users
  4. a simulation bank connection with 9 months of transaction history

Run the service

cargo run

Testing the Docker Image

Run docker run -d -p 8000:8000 --env-file .env [IMAGE ID] to start the containerized api-service in a detached process.

Note that when targeting a PlanetScale database, the containerized service requires that ?ssl_mode=verify_identity&ssl_ca=/etc/ssl/certs/ca-certificates.crt be appended to the DATABASE_URL to specify the Certificate Authority roots for the debian environment. (See DB Connectivity)

Publishing the Image

  1. Install Google Cloud SDK
  2. Ensure you have access to the Container Registrar service account in GCP IAM & Admin
  3. Run gcloud auth login using an account with access to the Container Registrar
  4. Build the image docker build . --tag tcmoore/bend-api-service
  5. Run docker tag tcmoore/bend-api-service gcr.io/bend-330614/api-service (You can find the project id here)
  6. Run docker push gcr.io/bend-330614/api-service

Once logged in, you can also use the publish.sh script.

DB Connectivity

The data-service can be pointed at a remote PlanetScale database, or at a local MySQL server with a DATABASE_URL like mysql://root:@localhost:3306/bend (see the example.env file)

Tunneling to Local API Service

We use ngrok for the purpose of Local Tunneling, such as when testing the Brex integration

Example: ngrok http --region=us --hostname=bend.ngrok.io 8000

Troubleshooting & Notes

  • Models use UUID v4 for primary keys
  • Note that PlanetScale is a UX layer over Vitess, and inherits some limitations from Vitess. This imposes some restrictions on what MySQL features we use; for example, TRIGGERS are not supported. UUID ids therefore must be set at the application level.
  • E0658 Unstable Errors during the Docker build probably indicate an outdated version of Rust in the Dockerfile
  • version `GLIBC_2.29' not found when running the Docker image indicates a mismatched binary between the build container and the runner (both must use the same version of debian). This unexpected failure first occurred in June 2022 likely as a result of building from the latest cargo-chef image—it was resolved by updating the runner to debian bullseye