Skip to content

THCLab/oca-repository-rs

Repository files navigation

OCA Repository

Installation

  1. Pull the Docker image for OCA Repository (be aware to NOT use latest tag for production deployment)
docker pull ghcr.io/thclab/oca-repository:2.0.0-rc.2
  1. Customize config file

config.yml:

application:
  host: 0.0.0.0
  port: 8000
  data_entries_path: "/tmp"
  # enable logging
  log_to_file: true
  # if log_to_file set to true and path not set default: /var/log/oca_repository.log
  log_path: "./logs/oca_repository.log"
  # path to directory where overlayfile definitions are located
  overlayfile_dir: "./core_overlays"

database:
  path: "./db"

cache_storage:
  path: "./cache"

search_engine:
  path: "./db_search"

ocafiles_cache:
  path: "./oca_repo_cache"
  1. Run an instance of OCA Repository
docker run -it --rm -p 8000:8000 -v $PWD/config.yml:/app/config/config.yml:ro ghcr.io/thclab/oca-repository:2.0.0-rc.2

Usage

See https://oca.colossi.network/ecosystem/oca-repository.html

Development

With Docker and latest release

git clone git@github.com:THCLab/oca-repository-rs.git

docker compose up

Locally with local build:

cargo build
./target/debug/oca-repository

This would start on default port 8000 instance of repository. You can then use curl for playing with api or simply go to https://repository.oca.argo.colossi.network/ and switch servers to localhost:8000 and use swagger (Remember to enable CORS in the browser).

Add OCA Bundle:

curl -XPOST http://127.0.0.1:8000/oca-bundles \
  -H "Content-type: text/plain" \
  --data-binary @ocafile.txt

If you need examples of OCA for development and testing check: https://github.com/thclab/ocafile-examples

Get OCA Bundle:

curl http://127.0.0.1:8000/oca-bundles/EF5ERATRBBN_ewEo9buQbznirhBmvrSSC0O2GIR4Gbfs

E2E tests (API)

The E2E tests use ocafile examples as a submodule. Ensure it is present before running tests:

cd oca-repository-rs
# if the submodule is not initialized
# git submodule update --init --recursive

Run the E2E test suite:

cargo test --test e2e_api

The test boots the server on a random port, posts an example ocafile, and exercises:

  • POST /oca-bundles
  • GET /oca-bundles/{said} (+ ?w=true)
  • GET /oca-bundles/{said}/steps
  • GET /oca-bundles/{said}/ocafile
  • GET /objects?said=...
  • GET /explore/{said}
  • GET /oca-bundles/{said}/data-entry (csv/xlsx)

About

OCA Repository implementation in Rust

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •