0.12.2 • Published 1 year ago

@gobend/jsdk v0.12.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

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
0.10.19

2 years ago

0.12.1

1 year ago

0.12.2

1 year ago

0.11.10

2 years ago

0.10.4

2 years ago

0.9.28

2 years ago

0.9.29

2 years ago

0.9.20

2 years ago

0.6.21

2 years ago

0.8.8

2 years ago

0.6.22

2 years ago

0.8.4

2 years ago

0.6.3-alpha

2 years ago

0.7.21

2 years ago

0.6.12

2 years ago

0.7.20

2 years ago

0.7.26

2 years ago

0.6.13

2 years ago

0.6.9-alpha

2 years ago

0.7.19

2 years ago

0.8.12

2 years ago

0.6.4-alpha

2 years ago

0.8.14

2 years ago

0.8.13

2 years ago

0.8.10

2 years ago

0.8.15

2 years ago

0.8.2

2 years ago

0.5.33-alpha

2 years ago

0.5.5-alpha

2 years ago

0.5.23-alpha

2 years ago

0.4.21-alpha

2 years ago

0.5.31-alpha

2 years ago

0.5.3-alpha

2 years ago

0.5.26-alpha

2 years ago

0.5.34-alpha

2 years ago

0.5.1-alpha

2 years ago

0.5.2-alpha

2 years ago

0.5.35-alpha

2 years ago

0.6.2-alpha

2 years ago

0.5.32-alpha

2 years ago

0.5.22-alpha

2 years ago

0.5.4-alpha

2 years ago

0.4.6-alpha

2 years ago

0.4.18-alpha

2 years ago

0.4.9-alpha

2 years ago

0.4.8-alpha

2 years ago

0.4.17-alpha

2 years ago

0.4.7-alpha

2 years ago

0.3.29-alpha

2 years ago

0.3.30-alpha

2 years ago

0.3.11-alpha

2 years ago

0.3.10-alpha

2 years ago

0.3.9-alpha

2 years ago

0.1.9-alpha

2 years ago

0.1.8-alpha

2 years ago

0.1.7-alpha

2 years ago

0.1.6-alpha

2 years ago

0.1.5-alpha

2 years ago

0.1.4-alpha

2 years ago

0.1.3-alpha

2 years ago