ardriveapp / turbo-upload-service

Turbo Upload Service that facilitates robust delivery of clients' fiat- or crypto-funded ANS-104 data items to Arweave.
https://ardrive.io
GNU Affero General Public License v3.0
7 stars 5 forks source link
arweave koa nodejs smartweave

Turbo Upload Service

Turbo is a robust, data bundling service that packages ANS-104 "data items" for reliable delivery to Arweave. It is architected to run at scale in AWS, but can be run in smaller scale, Docker-enabled environments via integrations with LocalStack. Additionally, local-development-oriented use cases are supported via integrations with ArLocal.

Turbo is powered by two primary services:

They are composed atop a common set of service dependencies including but not limited to:

Data items accepted by the service can be signed with Arweave, Ethereum, or Solana private keys.

Setting up the development environment

System Package Installation

For a compatible development environment, we require the following packages installed on the system:

Quick Start: Run all services in Docker

Once all of its dependencies are healthy, the Upload Service will start on port 3000. Visit its /api-docs endpoint for more information on supported HTTP routes.

NOTE: Database and queue state persistence across service runs are the responsibility of the operator.

Running the Upload Service locally

With a compatible system, follow these steps to start the Upload Service on its own on your local system:

Developers can alternatively use yarn start:watch to run the app in development mode with hot reloading provided by nodemon

Database

Scripts

Migrations

Knex is used to create and run migrations. To make a migration follow these steps:

  1. Add migration function and logic to schema.ts

  2. Run the yarn command to stage the migration, which generates a new migration script in migrations/ directory

    • yarn db:migrate:new MIGRATION_NAME (e.g. yarn db:migrate:new add_id_to_table)
  3. Construct the migration queries in src/db/arch/migrator.ts

  4. Update the generated migration file to call the proper migration script.

  5. Run the migration:

    • yarn db:migration:latest or yarn knex migration:up MIGRATION_NAME.TS
  6. Alternatively, run the migration against a specific environment file:

    • yarn dotenv -e .env.dev yarn db:migrate:latest

Rollbacks

You can rollback knex migrations using the following command:

Additional knex documentation can be found here.

Docker

Building Image

To build the container:

docker build --build-arg NODE_VERSION=$(cat .nvmrc |cut -c2-8) --build-arg NODE_VERSION_SHORT=$(cat .nvmrc |cut -c2-3) .

Docker Compose

Runs this service, against the most recent version of payment-service and arlocal, and local postgres instances.

docker compose up -d

Run just the upload service against migrated local postgres instance.

docker compose up upload-service --build

Tests

Unit and integration tests can be run locally or via docker. For either, you can set environment variables for the service via a .env file:

Unit Tests

Integration Tests